• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Pthread Priority
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pthread Priority


  • Subject: Re: Pthread Priority
  • From: Romain Marucchi <email@hidden>
  • Date: Wed, 20 Aug 2008 20:06:25 +0800

Allright got it tks to you and Luca.

And btw I take your advice Luca and switch for SCHED_RR.

Cheers guys,

ps: The first statement wasn't a question but a typo ;)



On Aug 20, 2008, at 7:15 PM, Ken Thomases wrote:

On Aug 20, 2008, at 3:01 AM, Romain Marucchi wrote:

Im porting a Linux app to the Mac and have the following code to set my thread priority?

Is that a question? ;)

The results are not as expected Im I missing something?

What were you expecting? How did the results differ?


...
...
	struct sched_param param;
	int policy = SCHED_OTHER;

SCHED_OTHER is non-portable.


priority = VERY_HIGH;

	param.sched_priority = priority;
	pthread_setschedparam( pthread_self(), policy, &param );

Have you considered checking the return code?

...
...


And I got the following def. for my priorities:

	VERY_LOW  = 10,
	LOW       = 5,
	NORMAL    = 0,
	HIGH 	  = -5,
	HIGH 	  = -10

One of the things that makes SCHED_OTHER non-portable is that some platforms use low numbers for low priority and high number for high priority, while others map in the reverse order. Also, the minimums and maximums can differ. So, these values are not portable, either.


Use the functions sched_get_priority_min(SCHED_OTHER) and sched_get_priority_max(SCHED_OTHER) to figure out what values to use.


I suggest you have a look here:

http://developer.apple.com/documentation/Darwin/Conceptual/KernelProgramming/scheduler/chapter_8_section_1.html

Cheers,
Ken

_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Pthread Priority (From: Romain Marucchi <email@hidden>)
 >Re: Pthread Priority (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: kext and std C++ algorithms?
  • Next by Date: Latest and greatest documenation for an OFFLINE machine
  • Previous by thread: Re: Pthread Priority
  • Next by thread: XCode 3 and javadoc
  • Index(es):
    • Date
    • Thread