Jump to content
  • Advertisement
Sign in to follow this  
themean

pthreads time slice problem

This topic is 2503 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi
I playing with pthreads and have problem with time slice ( 1 sec time slice )

Im on core to duo and make to threads which print different strings to console

Output is 1000 and more times first string and 1000 and more second and etc.

Any kind of idea how to make this simultaneously

Share this post


Link to post
Share on other sites
Advertisement
I'm having a little difficulty understanding the question, but it sounds to me like you want fine-grained control over context switching. I'm also going to assume you aren;t on a strictly real-time target stack.

If that's so, then you quite probably shouldn't be using threads, or you're needlessly worrying about context switching granularity.

If you just want to interleave two sets of output, do so in a single thread. Otherwise let the OS take care of the context switching. This is the whole point of the "threads" abstraction. Some operating systems provide sys calls that provide a hint that the scheduler should 'yield' control of the current processing unit to another thread, but I really don't think that's what you want here; the (proper) usage of yield calls is very niche indeed (so I'm not even going to provide a link wink.png).

Also, if you're judging this by eye, based on the interleaving of console output, then console buffering may further be confusing the problem, depending on what exactly each thread is printing.

If you were to share the higher-purpose of this piece of code, then some helpful suggestions on approaches might be forthcoming.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!