X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: atlas_wang AT yahoo DOT com (Wang Yong) Newsgroups: comp.os.msdos.djgpp Subject: Thread Swithing Time in pth1.3.7? Date: 11 Feb 2004 19:22:25 -0800 Organization: http://groups.google.com Lines: 85 Message-ID: <78a4a70a.0402111922.59344047@posting.google.com> NNTP-Posting-Host: 202.172.41.100 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1076556146 30292 127.0.0.1 (12 Feb 2004 03:22:26 GMT) X-Complaints-To: groups-abuse AT google DOT com NNTP-Posting-Date: Thu, 12 Feb 2004 03:22:26 +0000 (UTC) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hi, I am testing pth1.3.7 for DJGPP, and I am curious about the thread-switching time of it. See the following example: #include #include #include #include unsigned short uPort = 0x378; unsigned char uchData = 0x0; void *print_xs(void *unused) { while (1) { uchData ^= 0x01; /* bit0 */ outp(uPort, uchData); pth_yield(NULL); uchData ^= 0x01; /* bit0 */ outp(uPort, uchData); } return NULL; } void *print_ys(void *unused) { while (1) { uchData ^= 0x02; /* bit1 */ outp(uPort, uchData); pth_yield(NULL); uchData ^= 0x02; /* bit1 */ outp(uPort, uchData); } return NULL; } int main(void) { pth_init(); pth_spawn(NULL, print_xs, NULL); pth_spawn(NULL, print_ys, NULL); outp(uPort, uchData); while (1) { uchData ^= 0x04; /* bit2 */ outp(uPort, uchData); uchData ^= 0x04; /* bit2 */ outp(uPort, uchData); pth_yield(NULL); } pth_kill(); return 0; } I use osilliscope to measure the signal from parallel port and find that that the the time beteen rising edges is around 760 microseconds! To be honest, it is too large to use in a time-critical environment. The testing environment: CPU: PII-350 CHIPSET: INTEL 440BX MEMORY: 32M OS: MS-DOS 6.22 COMPILER: DJGPP 2.04 alpha 1 Makefile: CC = gcc CFLAGS = -O3 -Wall PROJ = thtst OBJS = thtst.o LIB_OPTS = -lpth -lsocket TARGET : $(PROJ).exe $(PROJ1).exe : $(OBJS) $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIB_OPTS) exe2coff $@ cat -B c:\djgpp\bin\cwsdstub.exe $(PROJ) >$@ rm -f $(PROJ) $(OBJS) : %.o : %.c $(CC) $(CFLAGS) -c $< .PHONY : clean clean : rm -f *.o rm -f $(PROJ).exe