• 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: Ken Thomases <email@hidden>
  • Date: Wed, 20 Aug 2008 06:15:04 -0500

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


  • Follow-Ups:
    • Re: Pthread Priority
      • From: Romain Marucchi <email@hidden>
References: 
 >Pthread Priority (From: Romain Marucchi <email@hidden>)

  • Prev by Date: RE: Pthread Priority
  • Next by Date: Unable to read symbols for...
  • Previous by thread: Re: Pthread Priority
  • Next by thread: Re: Pthread Priority
  • Index(es):
    • Date
    • Thread