pthreads vs carbon threads

tachyon
Unregistered
 
Post: #1
Okay, this has been driving me crazy. I have implemented threading in my engine using both pthreads and carbon threads. I run the engine with carbon threading enabled and it works fine, using a decent amount of cpu. Now, I run the engine with pthreads enabled and the cpu usage shows 100%!

The problem with carbon threading was that I couldn't choose the scheduling priority (i wanted the threads to have higher priority than the gui effects, which seem to be extremely high (expose etc), as this was causing stuttering in my audio stream)

So the pthreads implementation fixed my problem with the scheduling, ie the gui effects don't interfere with my engine anymore. However, it shows 100% cpu usage.

Has anyone every experienced this or know of any issues with pthreads?

Sorry for rambling, i've been trying to work this out all day. Any help or comments would be appreciated. Smile
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
Probably what you want is not a raised-priority thread, but a round-robin-scheduled thread. Round-robin threads don't get any more time than others, they're just guaranteed to get it regularly. This is what iTunes uses.

I don't remember the details of how to set it up, but a search in the mac-games-dev list archives should turn it up fairly quickly, or perhaps you can find it in the headers.
Quote this message in a reply
tachyon
Unregistered
 
Post: #3
hi, thanks for the reply. My implementation using pthreads was actually using round-robin scheduling. . Is there anyway to do this with carbon threads?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
Carbon Threads are implemented on top of pthreads; anything you can do with Carbon Threads you can do with pthreads.

I've never used Carbon Threads and hope never to!
Quote this message in a reply
tachyon
Unregistered
 
Post: #5
thanks for you help.

I found that you can set the thread_policy with the mach function thread_policy_set() which has solved my problems Smile
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Named Mutex in pthreads maaaaark 7 6,791 Mar 31, 2005 08:49 AM
Last Post: DoG
  Threads Pancho 9 3,928 Nov 26, 2002 01:18 PM
Last Post: henryj