ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/main_unix.cpp
(Generate patch)

Comparing SheepShaver/src/Unix/main_unix.cpp (file contents):
Revision 1.13 by gbeauche, 2003-11-03T21:28:25Z vs.
Revision 1.14 by gbeauche, 2003-11-10T16:05:52Z

# Line 1152 | Line 1152 | static void *tick_func(void *arg)
1152  
1153   void Set_pthread_attr(pthread_attr_t *attr, int priority)
1154   {
1155 <        // nothing to do
1155 > #ifdef HAVE_PTHREADS
1156 >        pthread_attr_init(attr);
1157 > #if defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
1158 >        // Some of these only work for superuser
1159 >        if (geteuid() == 0) {
1160 >                pthread_attr_setinheritsched(attr, PTHREAD_EXPLICIT_SCHED);
1161 >                pthread_attr_setschedpolicy(attr, SCHED_FIFO);
1162 >                struct sched_param fifo_param;
1163 >                fifo_param.sched_priority = ((sched_get_priority_min(SCHED_FIFO) +
1164 >                                              sched_get_priority_max(SCHED_FIFO)) / 2 +
1165 >                                             priority);
1166 >                pthread_attr_setschedparam(attr, &fifo_param);
1167 >        }
1168 >        if (pthread_attr_setscope(attr, PTHREAD_SCOPE_SYSTEM) != 0) {
1169 > #ifdef PTHREAD_SCOPE_BOUND_NP
1170 >            // If system scope is not available (eg. we're not running
1171 >            // with CAP_SCHED_MGT capability on an SGI box), try bound
1172 >            // scope.  It exposes pthread scheduling to the kernel,
1173 >            // without setting realtime priority.
1174 >            pthread_attr_setscope(attr, PTHREAD_SCOPE_BOUND_NP);
1175 > #endif
1176 >        }
1177 > #endif
1178 > #endif
1179   }
1180  
1181  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines