*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->Tru64 Unix man pages -> pthread_use_only_cpu (3)              
Title
Content
Arch
Section
 

pthread_use_only_cpu(3)

Contents


NAME    [Toc]    [Back]

       pthread_use_only_cpu  - Restricts a thread to running only
       on the specified CPU. If that CPU is unavailable  for  any
       reason, the thread will not run

SYNOPSIS    [Toc]    [Back]

       #include <cpuset.h> #include <sys/types.h>

       int pthread_use_only_cpu(
               pthread_t thread,
               cpuid_t cpu_id,
               long flag );

LIBRARY    [Toc]    [Back]

       DECthreads POSIX 1003.1c Library (libpthread.so)

PARAMETERS    [Toc]    [Back]

       Thread  to  be  restricted  to use only the specified CPU.
       Currently only PTHREAD_BINDCPU_INFLEXIBLE is defined,  and
       must be specified.

DESCRIPTION    [Toc]    [Back]

       This  routine  restricts  thread to cpu_id, preventing the
       thread  from  utilizing  any  other  available   processor
       resources  even  when  cpu_id  may be busy for an extended
       time with other work or is otherwise unavailable.

       This function can be  used  only  with  System  Contention
       Scope  (SCS)  threads,  that is, threads that were created
       using an attributes object with the scope attribute set to
       PTHREAD_SCOPE_SYSTEM.

       Specifying a cpu_id value of CPU_NONE removes the restriction
 from the thread, allowing it to again take  advantage
       of  any available CPU when the CPU on which it last ran is
       busy.

       cpu_id will become unavailable if the corresponding CPU is
       removed  from  the  processor  set in which the process is
       running or if it is taken off-line.  In  this  event,  any
       thread  that  is  restricted  to cpu_id will not run until
       pthread_use_only_cpu is  called  from  another  thread  to
       change or remove the thread's restriction.

       Threads  that  have  not been restricted to a specific CPU
       using this function are typically scheduled to run on  the
       CPU  they  last  used, in order to take advantage of valid
       cache and translation buffer  (TB)  entries.  However,  if
       that  CPU  remains  busy  with other work, the threads may
       instead be run on another CPU if available.  This  default
       behavior is the most effective except in extremely unusual
       circumstances, so this function should be used  only  with
       great caution.  Improper use of this function can substantially
 degrade application performance;  proper  use  will
       rarely improve performance measurably (if at all).

       This routine does not prevent cpu_id from performing other
       work. Restricting a thread to a CPU is  rarely  beneficial
       to  an  application since other threads of equal or higher
       priority may be run by cpu_id, and, in  addition  to  preventing
  thread  from executing, this activity will likely
       invalidate cache and TB entries used  by  thread,  thereby
       removing the principal advantages of having restricted the
       thread. Furthermore, giving a thread a very high  priority
       is  not  sufficient  to  guarantee  exclusive use of a CPU
       since page faults, interrupts, or blocking system calls of
       even  very  short  duration  can  permit  other threads to
       obtain the CPU. To obtain exclusive use of a CPU, see  the
       processor_sets(4) reference page.

RETURN VALUES    [Toc]    [Back]

       If an error condition occurs, the target thread's scheduling
  restrictions  remain  unchanged,  and  this   routine
       returns  an  integer  value  indicating the type of error.
       Possible return values are as follows: Successful  completion.
   The  value  specified by cpu_id is invalid, or the
       flag is invalid.  The specified thread is a  Process  Contention
  Scope  thread.   The  specified  thread  does not
       exist.

ERRORS    [Toc]    [Back]

       None

SEE ALSO    [Toc]    [Back]

      
      
       Functions:    pthread_create(3),     pthread_attr_init(3),
       pthread_attr_setscope(3),              pthread_rad_bind(3)
       pthread_rad_attach(3), processor_sets(3)

       Manuals: Guide to DECthreads and Programmer's Guide



                                          pthread_use_only_cpu(3)
[ Back ]
 Similar pages
Name OS Title
current_thread Tru64 General: Is a pointer to the currently running kernel thread
current_task Tru64 General: Returns a pointer to the task structure associated with the currently running kernel thread
nfs_portmon HP-UX restricts NFS services to clients from privileged ports
ERR_GET_LIB Tru64 Get library, function and reason code
ERR_GET_FUNC OpenBSD get library, function and reason code
ERR_GET_REASON OpenBSD get library, function and reason code
ERR_GET_LIB OpenBSD get library, function and reason code
ERR_GET_REASON Tru64 Get library, function and reason code
ERR_GET_LIB NetBSD get library, function and reason code
ERR_GET_FUNC Tru64 Get library, function and reason code
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service