C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 7th, 2008, 12:35 PM
mynickmynick mynickmynick is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 7 mynickmynick Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 h 29 m 35 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old May 7th, 2008, 05:35 PM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,319 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 11 h 12 m
Reputation Power: 49
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.

Reply With Quote
  #3  
Old May 9th, 2008, 05:42 AM
etienne141's Avatar
etienne141 etienne141 is offline
Paris est magique!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: France!
Posts: 357 etienne141 User rank is Second Lieutenant (5000 - 10000 Reputation Level)etienne141 User rank is Second Lieutenant (5000 - 10000 Reputation Level)etienne141 User rank is Second Lieutenant (5000 - 10000 Reputation Level)etienne141 User rank is Second Lieutenant (5000 - 10000 Reputation Level)etienne141 User rank is Second Lieutenant (5000 - 10000 Reputation Level)etienne141 User rank is Second Lieutenant (5000 - 10000 Reputation Level)etienne141 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 8 h 9 m 35 sec
Reputation Power: 79
Send a message via ICQ to etienne141 Send a message via MSN to etienne141
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:
NPTL still has a few non-conformances with POSIX.1:
- Threads do not share a common nice value.


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.

Reply With Quote
  #4  
Old May 12th, 2008, 06:52 AM
mynickmynick mynickmynick is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 7 mynickmynick Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 h 29 m 35 sec
Reputation Power: 0
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)

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Nice for pthreads?? (only one pthread affected?)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT