On May 22, 2007, at 11:46 PM, Eric Blossom wrote:
pthread_attr_setschedpolicy is not the same thing as
sched_setscheduler. It's for setting up the attribute that is passed
pthread_create.
Touché. Thanks for pointing that out ... should have been
"pthread_setschedparam()" instead. This routine is, if I'm reading
the MAN pages correctly, an exact parallel to "sched_setscheduler()",
but in pthread terms. Here's the basic code:
-------
int policy = SCHED_FIFO
pthread_t this_thread = pthread_self ();
int priority = (sched_get_priority_max (policy) +
sched_get_priority_min (policy)) / 2;
struct sched_param param;
memset (¶m, 0, sizeof (param));
param.sched_priority = priority;
int result = pthread_setschedparam (this_thread, policy, ¶m)
if (result != 0) {
printf ("Error %d doing 'pthread_setschedparam'.\n", errno);
...
-------
Compare that with "gr_realtime.cc":
----
int policy = SCHED_FIFO;
int pri = (sched_get_priority_max (policy) +
sched_get_priority_min (policy)) / 2;
int pid = 0; // this process
struct sched_param param;
memset(¶m, 0, sizeof(param));
param.sched_priority = pri;
int result = sched_setscheduler(pid, policy, ¶m);
if (result != 0){
....
--------
You'll notice that the 2 differences are (1) having to get the
current pthread instead of the PID; and (2) using
"pthread_setschedparam()" instead of "sched_setscheduler()".
Interestingly, at least on OSX 10.4.9, all policies have a (min,max)
priority of (15,47), and the default for any process is the mid-point
(31). Thus for OSX, "real time" priority needs to be closer to the
MAX than the mid-point. The default policy is "Other" (1), whatever
that is.
But, again, for some reason 'configure' isn't registering that
pthreads are available on OSX 10.4 ... which they clearly are. - MLD
_______________________________________________
Discuss-gnuradio mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio