|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Nice for pthreads?? (only one pthread affected?)
With Linux kernel 2.6
nice() called inside a pthread affects only the calling thread or all threads of the process?? (May be in POSIX it affects the process, but Linux is not fully POSIX compliant cause threads are actually processes for the kernel scheduler) In case it affects all process' threads, is there a call something like pthread_nice() to affect one thread only? Please do not answer set_sched_param() cause that will not work for SCHED_OTHER policy as stated here "pthread_setschedparam sets the scheduling parameters for the thread target_thread as indicated by policy and param. policy can be either SCHED_OTHER (regular, non-realtime scheduling), SCHED_RR (realtime, round-robin) or SCHED_FIFO (realtime, first-in first-out). param specifies the scheduling priority for the two realtime policies. See sched_setpolicy(2) for more information on scheduling policies. " at the linuxmanpages |
|
#2
|
|||
|
|||
|
Consider a simple test. Call getpriority in the thread and see what the value is before and after a nice call. See what effect it has on the parent nice value before and efter the the thread starts and exits.
I had never considered doing an in-thread nice, always just used a child process running at another priority. It certainly will not port to other unix systems. |
|
#3
|
||||
|
||||
|
Reading man pthreads on a Linux machine: man pthread
Two implementations of threads in Linux are discussed (the older being likely to get deprecated); rather interesting. NPTL threads (used by default) are quite POSIX compliant, except: Quote:
Yet, I would not recommend to tweak too much those things, nor assume that your kernel implementation uses this or that. Because: - appropriate use of nice() is quite rare - you have to renounce to portability (on another OS, or a newer/older version of your actual kernel)
__________________
etienne:~ > %blow fg: %blow: no such job There are 10 kind of people: - those who know binary - those who don't. |
|
#4
|
|||
|
|||
|
i quite agree but SCHED_RR (real time with priority) seems too strict (there is often a risk of starving thread if the SW architecture is not very careful and quite simple)
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > Nice for pthreads?? (only one pthread affected?) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|