Date: Mon, 18 Sep 2000 14:36:08 -0400 (EDT) From: Zhiui Zhang <zzhang@cs.binghamton.edu> To: freebsd-hackers@freebsd.org Subject: How to time a system call Message-ID: <Pine.SOL.4.21.0009181425060.6901-100000@jade>
next in thread | raw e-mail | index | archive | help
A friend asks me what will happen if more than one process trying to read the stdin at the same time. There is no way to guarantee that any particular keyboard input will be accepted by a particular process. Since a system call is atomic, this makes me wonder how long it takes to do a system call, like read(), on a 500Mhz PC? How to time it? I later write a program that forks. So that two processes tries to read the stdin at the same time. I use read() to read one character at a time. Each process read 1000 characters and write what they read to a file. I use I/O redirect to let them read from the same file instead of keyboard. I find out that one process always call 1000 read()s before the second has a chance to call read(). I hope someone can give me a clue on how this is happening. Maybe the scheduling quantum (100ms?) is just enough for doing 1000 read() system calls. Is there any easy way to time a system call (perhaps with minor modifications of the kernel)? Any help is appreciated. -Zhihui To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SOL.4.21.0009181425060.6901-100000>