On Sat, 20 Aug 2005, Rafi Gordon wrote: > may I ask ehat is the recommnded way to write a a busy wait loop? > If I am not wrong there is no "noop" command in "C" ; is there a noop > is asm to achieve this ? or simply a loop which just do dummy > operation > like incrementing some integer ?
i suggest you look at the code of nanosleep, and try to understand how it handles under-2-milliseconds-sleeps-when-process-is-in-SCHED-FIFO-scheduling-policy. the man page sais it does a busy wait. see how it does that. note that in order for a process to move into SCHED_FIFO scheduling policy, it has to be run by root - and i imagine your application is run by normal users, not by root. > Regarding gettimeofday() discussion which evolved from this thread: > this is an interesting topic in itself and I am glad to see it here. > I have a little remark regarding this(I may be wrong) > Guy Keren said: > " for the gory details - arch/XXX/kernel/time.c - > do_gettimeofday()." > > I had looked at the sys call wrapper which calls do_gettimeofday(), > which is in kernel/time.c (NOT under arch/... subtree) > and I saw there a put_user() call , which means > copying to user space if I am not wrong. > Copying to user space seems to me a heavy operation > (even if we only pass a little timeval struct). yet, on CPUs of the last 2-3 years, this operation takes far less then a micro-second. i imagine it took less them that also on CPUs from 4-5 years ago, but i did not measure it back then. -- guy "For world domination - press 1, or dial 0, and please hold, for the creator." -- nob o. dy ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
