c++ - What happens when pthreads wait in mutex_lock/cond_wait? -



c++ - What happens when pthreads wait in mutex_lock/cond_wait? -

i have programme should maximum out of cpu.

it multithreaded via pthreads job apart fact "only" cores 60% load not plenty in opinion.

i searching reason , asking myself (and hereby you) if blocking functions mutex_lock/cond_wait candidates?

what happens when thread cannot run on in such function?

does pthread switch thread handles or does thread yield time scheme , if latter case, can alter behavior?

regards,

nobody

more information setting 1 mainthread fills taskpool , countless workers fetch jobs there , wait on conditional signaled via broadcast when serialized calculation done. go on values calculation until done, deliver mail service , fetch next job...

on typical modern pthreads implementation, each thread managed kernel not unlike separate process. blocking phone call pthread_mutex_lock or pthread_cond_wait (but also, say, read) yield time system. scheme find eligible thread schedule, whether in process or process, , run it.

if programme taking 60% of cpu, more blocked on i/o on pthread operations, unless have done way granular pthread operations.

c++ multithreading pthreads conditional mutex

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -