Sad Clouds <[email protected]> wrote:

> Well, quite often you need to call time function in a loop. For
> example, you have a loop that accepts network packets, or connections
> and every so often you need to have current system time. The resolution
> of the timer can be specific to application, i.e. it could be seconds,
> milliseconds, or microseconds.a
>
> uint64_t current_time;
> while(1)
> {
>       get_network_data();
>       current_time = update_current_time();
>       ...
>       use_current_time();
> }
>
> So in a tight loop, if update_current_time() calls clock_gettime() on
> every loop iteration, what would kill performance.

The advantage of using something like a time() syscall is that it could allow 
the scheduler to give the CPU to another process. If you did implement a 
mmap()ed time interface, this would not happen and the process would loop
in user space and thus be allowed to keep the CPU until the quantum is expired.

Jörg

-- 
 EMail:[email protected] (home) Jörg Schilling D-13353 Berlin
       [email protected]                (uni)  
       [email protected] (work) Blog: 
http://schily.blogspot.com/
 URL:  http://cdrecord.berlios.de/private/ ftp://ftp.berlios.de/pub/schily
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to