topics that matter; ideas worth sharing

share a tip, submit a link, add something new

Scheduling in the user threads library

March 16, 2001, 05:18 PM —  Unix Insider — 

The kernel dispatcher and associated subsystems provide for the prioritization and scheduling of kernel threads in one of several bundled scheduling classes. The details of the implementation are covered in a series of past Inside Solaris columns which began in October 1998.


Solaris currently ships with two threads libraries: libthread.so, for support of the Solaris threads interfaces, and libpthread.so, the POSIX (Portable Operating System Interface for Unix) threads APIs. User threads are created by a call to either thr_create(3THR) (Solaris threads) or pthread_create(3THR) (POSIX threads). The Solaris threads library was originally introduced in Solaris 2.2. At the time, the POSIX threads specification had not been completed. When the POSIX draft was ready, an implementation of the POSIX threads library was developed and began shipping in Solaris 2.6. Both libraries continue to be bundled with Solaris, but we recommend that any new development use the POSIX interfaces, as new features and functionality are being integrated into the POSIX code but not necessarily into the Solaris threads library.


User threads do not have a notion of scheduling classes, such as the timeshare and realtime classes implemented in the kernel. POSIX threads do provide the notion of several scheduling policies, which can be specified by the programmer as part of a thread's attributes. Attributes, which were introduced by POSIX, allow the programmer to alter the behavior of a user thread or synchronization object, and can be found in both. The creation of POSIX threads and synchronization objects permits the passing of an attribute's structure, which must be initialized along with any changes to specific attributes prior to the create call in order to create the thread or synchronization object.


As of Solaris 8, the supported attributes for a thread are:

  • contentionscope: PTHREAD_SCOPE_PROCESS or PTHREAD_SCOPE_SYSTEM. Determines if the thread is bound or unbound (more on this below).
  • detachstate: Determines whether or not to save the thread's state when it terminates, so that it is joinable. That is, another thread in the same process can issue a pthread_join() on the thread ID and collect the thread's exit status.
  • stackaddr: User-specified thread stack address. By default, the system will determine the stack address based on existing address-space mappings.
  • stacksize: User-specified stack size. Default is 1 MB for a 32-bit process, 2 MB for a 64-bit process.
  • priority: A user-specified priority. Default is zero.
  • policy: The scheduling policy. Default is SCHED_OTHER, meaning that Solaris will provide fixed priority behavior.
  • guardsize: Specifies protection against stack overflow by placing a guard page (red zone) around the mapped stack pages.
  • inheritsched: Default value of PTHREAD_INHERIT_SCHED allows new threads to inherit the scheduling policy of the calling thread.


Each of these attributes has a corresponding pair of POSIX APIs for reading (get) and altering (set) a specific attribute. For example, determining or changing the stack size attribute is accomplished using pthread_attr_setstacksize (3THR) and pthread_attr_getstacksize (3THR). The programmer cannot alter or read an attribute through

I like it!
Post a comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
Resources
White Paper

Symantec Backup Exec 12 and Backup Exec System Recovery 8 deliver industry leading Windows data protection and system recovery. Download this whitepaper to find out the top reasons to upgrade and how to get continuous data protection and complete system recovery.

Webcast

Data and system loss — from a hard drive failure, malicious attack, natural disaster, or simple human error — can happen anytime. Don’t leave your business vulnerable. Make sure you have a secure recovery strategy in place. Symantec's latest backup and system recovery technology can efficiently restore critical applications, individual emails and documents and even restore your entire system in minutes in the event of a loss.

White Paper

Businesses face a growing challenge to ensure that the IT environment is properly protected. Backup Exec 12 integrates with other applications in the Symantec family of products, to complement your current data protection strategy, keep your data securely backed up and make it recoverable when you need it most.

Free stuff
Featured Sponsor

Get a broad understanding of important regulations and how you can make sure your site is in adherence.





Learn how VeriSign SGC-enabled SSL Certificates can help improve site security and customer confidence in the free white paper, "How to Offer the Strongest SSL Encryption." In this paper you will learn the differences between weak and strong encryption and what they mean for your site's performance.

Get VeriSign's free white paper: "The Latest Advancements in SSL Technology" and learn about the benefits of strong SSL encryption, Extended Validation (EV) SSL and security trust marks and what these SSL offerings can do for your site.

Now with Extended Validation (EV) SSL available from VeriSign, you can show your customers that they can trust your site. Learn about EV SSL benefits in this free VeriSign white paper.

More Resources