Threads scheduling services.
[Threads management services.]

Collaboration diagram for Threads scheduling services.:

Detailed Description

Thread scheduling services.

Xenomai POSIX skin supports the scheduling policies SCHED_FIFO, SCHED_RR and SCHED_OTHER.

The SCHED_OTHER policy is mainly useful for user-space non-realtime activities that need to synchronize with real-time activities.

The SCHED_RR policy is only effective if the time base is periodic (i.e. if configured with the compilation constant CONFIG_XENO_OPT_POSIX_PERIOD or the xeno_nucleus module parameter tick_arg set to a non null value). The SCHED_RR round-robin time slice is configured with the xeno_posix module parameter time_slice, as a count of system timer clock ticks.

The SCHED_SPORADIC policy is not supported.

The scheduling policy and priority of a thread is set when creating a thread, by using thread creation attributes (see pthread_attr_setinheritsched(), pthread_attr_setschedpolicy() and pthread_attr_setschedparam()), or when the thread is already running by using the service pthread_setschedparam().

See also:
Specification.


Functions

int sched_get_priority_min (int policy)
 Get minimum priority of the specified scheduling policy.
int sched_get_priority_max (int policy)
 Get maximum priority of the specified scheduling policy.
int sched_rr_get_interval (int pid, struct timespec *interval)
 Get the round-robin scheduling time slice.
int pthread_getschedparam (pthread_t tid, int *pol, struct sched_param *par)
 Get the scheduling policy and parameters of the specified thread.
int pthread_setschedparam (pthread_t tid, int pol, const struct sched_param *par)
 Set the scheduling policy and parameters of the specified thread.
int sched_yield (void)
 Yield the processor.


Function Documentation

int pthread_getschedparam ( pthread_t  tid,
int *  pol,
struct sched_param *  par 
)

Get the scheduling policy and parameters of the specified thread.

This service returns, at the addresses pol and par, the current scheduling policy and scheduling parameters (i.e. priority) of the Xenomai POSIX skin thread tid. If this service is called from user-space and tid is not the identifier of a Xenomai POSIX skin thread, this service fallback to Linux regular pthread_getschedparam service.

Parameters:
tid target thread;
pol address where the scheduling policy of tid is stored on success;
par address where the scheduling parameters of tid is stored on success.
Returns:
0 on success;

an error number if:

  • ESRCH, tid is invalid.
See also:
Specification.

int pthread_setschedparam ( pthread_t  tid,
int  pol,
const struct sched_param *  par 
)

Set the scheduling policy and parameters of the specified thread.

This service set the scheduling policy of the Xenomai POSIX skin thread tid to the value pol, and its scheduling parameters (i.e. its priority) to the value pointed to by par.

When used in user-space, passing the current thread ID as tid argument, this service turns the current thread into a Xenomai POSIX skin thread. If tid is neither the identifier of the current thread nor the identifier of a Xenomai POSIX skin thread this service falls back to the regular pthread_setschedparam() service, hereby causing the current thread to switch to secondary mode if it is Xenomai thread.

Parameters:
tid target thread;
pol scheduling policy, one of SCHED_FIFO, SCHED_RR or SCHED_OTHER;
par scheduling parameters address.
Returns:
0 on success;

an error number if:

  • ESRCH, tid is invalid;
  • EINVAL, pol or par->sched_priority is invalid;
  • EAGAIN, in user-space, insufficient memory exists in the system heap, increase CONFIG_XENO_OPT_SYS_HEAPSZ;
  • EFAULT, in user-space, par is an invalid address;
  • EPERM, in user-space, the calling process does not have superuser permissions.
See also:
Specification.
Examples:
rtcan_rtt.c.

int sched_get_priority_max ( int  policy  ) 

Get maximum priority of the specified scheduling policy.

This service returns the maximum priority of the scheduling policy policy.

Parameters:
policy scheduling policy, one of SCHED_FIFO, SCHED_RR, or SCHED_OTHER.
Return values:
0 on success;
-1 with errno set if:
  • EINVAL, policy is invalid.
See also:
Specification.

int sched_get_priority_min ( int  policy  ) 

Get minimum priority of the specified scheduling policy.

This service returns the minimum priority of the scheduling policy policy.

Parameters:
policy scheduling policy, one of SCHED_FIFO, SCHED_RR, or SCHED_OTHER.
Return values:
0 on success;
-1 with errno set if:
  • EINVAL, policy is invalid.
See also:
Specification.

int sched_rr_get_interval ( int  pid,
struct timespec *  interval 
)

Get the round-robin scheduling time slice.

This service returns the time quantum used by Xenomai POSIX skin SCHED_RR scheduling policy.

In kernel-space, this service only works if pid is zero, in user-space, round-robin scheduling policy is not supported, and this service not implemented.

Parameters:
pid must be zero;
interval address where the round-robin scheduling time quantum will be returned on success.
Return values:
0 on success;
-1 with errno set if:
  • ESRCH, pid is invalid (not 0).
See also:
Specification.

int sched_yield ( void   ) 

Yield the processor.

This function move the current thread at the end of its priority group.

Return values:
0 
See also:
Specification.


Generated on Mon Mar 24 18:02:44 2008 for Xenomai API by  doxygen 1.5.3