Post by m***@public.gmane.orgHi Micke,
Post by mickekthread_t *t;
pid_t tid;
t = (kthread_t *)pthread_self();
tid = (pid_t)&t->t_tid;
that works I think, the t_tid is the current threads id right?
sched_setscheduler(tid, SCHED_FIFO, &sp);
: No such process
I want to schedule this thread only, do I have the wrong thread id?
in linux sched_setscheduler works for thread id, is the same true in solaris?
Reading the man page for sched_setscheduler(3RT) says the first argument
is a pid (process id), not a tid (thread id) (so sched_setscheduler() is
process-wide,
not specific thread). And you can use 0 for the first argument to
refer to yourself. If you want to change scheduling class for a
specific thread,
take a look at pthread_setschedparam(3c).
To illustrate:
struct schedparam sp;
...
sched_setscheduler(getpid(), SCHED_FIFO, &sp);
does the same to the current process which the following:
struct schedparam sp;
...
pthread_setschedparam(pthread_self(), SCHED_FIFO, &sp);
does to the current thread.
These:
http://www.opengroup.org/onlinepubs/7990989775/xsh/pthread.h.html
http://docs.sun.com/app/docs/doc/819-2252/pthreads-5
http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html
seem a reasonable start for what this is all about. The following:
http://www.ibm.com/developerworks/linux/library/l-threading.html
gives a good history of the state Linux threading support used to be in;
recently (in the last two years) things settled to compatibility with
POSIX threads, so that's only context in the sense why "good" docs on how
to create multithreaded programs under Linux are hard to find ... and why
Linux people often do Linux-specific hacks ...
FrankH.