This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Application Timeslicing


Is there anyway to allow an application to give up just its timeslice?

What I would like to do is poll a counter, and if it hasn't changed,
I would like to just give up the rest of my timeslice.
(I am trying to avoid the kernel overhead of semaphores and such.)

I have read somewhere that ring buffers are used for speedy IPC without system calls. But
there has to be some way to avoid race conditions between the two processes.


What would sleep(0) do exactly?
Would sleep say "Hey, you want to sleep for zero time, so I'll just return control back to you",
or would it say "Well since you called me, you are losing your timeslice no matter what,
but you will be ready to run the next time the scheduler sees fit"?



Here is basically the code sequence


Process 1 (Consumer):
while(counter == 0)
   give up timeslice;

Process 2 (Producer):
while(counter == MAX_COUNT)
   give up timeslice;

(In my particular scenario, the producer will most likely produce much faster than the consumer can consume.)

Thanks!
Brian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]