# Thread Scheduling

- ## Contention Scope

  - Bound Threads: System Scheduling Scope (default in HP-UX)
  - Unbound Threads: Process Scheduling Scope
  - Set at thread creation via attribute passed to pthread_create()

- ## Scheduling Policies and Priorities

  - Realtime: SCHED_FIFO, SCHED_RR (priority = 0 to 31)
  - Timeshare: SCHED_OTHER, SCHED_TIMESHARE, SCHED_HPUX
    - (priority = -256 to -129, default = -192)

- ## Set thread attributes at thread creation or dynamically.

  - Creation: (only set functions shown)
  - int pthread_attr_setschedpolicy(*attr, int policy);
  - int pthread_attr_setschedparam(*attr, struct sched_param *sp);
  - sp->priority is the relevant field
  - Dynamic:
  - int pthread_setschedparam(pthread_t tid, int policy, struct sched_param *param);

Previous slide | Next slide | Back to first slide | View graphic version