42 self->index,
43 (my_policy == SCHED_FIFO ? "FIFO"
44 : (my_policy == SCHED_RR ? "RR"
45 : (my_policy == SCHED_OTHER ? "OTHER" 46 : "unknown"))),
47 my_param.sched_priority);
48 return NULL;
49 }
50
51 int main (int argc, char *argv[])
52 {
53 int count, status;
54
55 rr_min_priority = sched_get_priority_min (SCHED_RR);
56 if (rr_min_priority == -1) {
57 #ifdef sun
58 if (errno == ENOSYS) {
59 fprintf (stderr, "SCHED_RR is not supported.\n");
60 exit (0);
61 }
62 #endif
63 errno_abort ("Get SCHED_RR min priority");
64 }
65 for (count = 0; count < THREADS; count++) {
66 threads[count].index = count;
67 status = pthread_create (
68 &threads[count].id, NULL,
69 thread_routine, (void*)&threads[count]);
70 if (status != 0)
71 err_abort (status, "Create thread");
72 }
73 for (count = 0; count < THREADS; count++) {
74 status = pthread_join (threads[count].id, NULL);
75 if (status != 0)
76 err_abort (status, "Join thread");
77 }
78 printf ("Main exiting\n");
79 return 0;
80 }
5.5.3 Contention scope and allocation domain
int pthread_attr_getscope (
const pthread_attr_t *attr, int *contentionscope);
int pthread_attr_setscope (
pthread_attr_t *attr, int contentionscope);
Besides scheduling policy and parameters, two other controls are important in realtime scheduling. Unless you are writing a realtime application, they probably don't matter. If you are writing a realtime application, you will need to find out which settings of these controls are supported by a system.
The first control is called
Pthreads provides the thread pthread_attr_setscope
will return ENOTSUP.
The second control is
There is no Pthreads interface to set a thread's allocation domain. The POSIX.14 (Multiprocessor Profile) working group considered proposing standard interfaces, but the effort was halted by the prospect of dealing with the wide range of hardware architectures and existing software interfaces. Despite the lack of a standard, any system supporting multiprocessors will have interfaces to affect the allocation domain of a thread.