From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,d962deee5162cb43,start X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1993-11-18 13:26:53 PST Path: gmd.de!xlink.net!howland.reston.ans.net!cs.utexas.edu!not-for-mail From: swanton@puffin.usmcs.maine.edu (George P. Swanton) Newsgroups: comp.unix.osf.osf1 Subject: [Q] Regarding OSF/1 threads Date: 18 Nov 1993 14:27:54 -0600 Organization: UTexas Mail-to-News Gateway Sender: daemon@cs.utexas.edu Message-ID: <9311182027.AA02358@puffin.usmcs.maine.edu> NNTP-Posting-Host: news.cs.utexas.edu I've done a very simple 'benchmark' on our Alpha's (3K/400 OSF1 1.2) to see how pthreads/cmathreads compared to standard processes with regard to context switching. Gist of the thing: create two threads or processes, alternate executing (essentially) gettimeofday(&start, NULL); /* actually occurs only once */ for(;;) { if (++count >= 10000) break; [cma/pthread/sched]_yield(); /* as appropriate */ } gettimeofday(&stop, NULL); dump the equivalent of (stop - start) Not much to it really. The results were not what I expected. Basically the processes were consistently faster: abstraction avg time (usec) to execute cmathread 199104 pthread 192272 process 164944 control 976 (single thread executing for loop w/o switching) (note that the resolution of the timer is 976 usec) I had expected threads to be the faster. My feeling is that either I've made an invalid assumption about the benchmark or all three abstractions somehow map to the same Mach abstraction and processes are more direct about it. Comments? Profiling shows the following (digested, each for 1 thread/process, BTW: anyway to get statistics for ALL threads?) cmathreads cycl/ calls %cycles call sec procedure 5000 36.22 12 .0004 cma_yield (blah/DECthreads/COMMON/cma_thread.c) 5000 9.05 3 .0001 swtch_pri (blah/alpha/usr/include/mach/syscall_sw.h) 2 30.21 50000 .0003 (benchmark procedure) pthreads cycl/ calls %cycles call sec procedure 5000 36.85 12 .0004 pthread_yield (blah/DECthreads/COMMON/cma_thread.c) 5000 9.21 3 .0001 swtch_pri (blah/alpha/usr/include/mach/syscall_sw.h) 2 30.73 50038 (benchmark procedure) unix process cycl/ calls %cycles call sec procedure 4999 21.34 3 .0001 sched_yield (blah/librt/alpha/schyield.s) 1 78.27 55009 .0004 (benchmark procedure) swtch_pri apparently traps to the kernel (eg, .../mach/syscall_sw.h) It makes sense that sched_yield does the same. I cant decide whether cma/pthread_yield are just simple library routines or another trap stub. I thought OSF/1 threads were a user-level implementation, is this incorrect? Any feedback anyone wishes to offer is appreciated. Thanks George P Swanton swanton@moose.usmcs.maine.edu