SCHED_RR
SCHED_OTHER
[_POSIX_PRIORITY_SCHEDULING]
sched_get_priority_min.........................................................
int sched_get_priority_min (
int policy);
Return the minimum integer priority allowed for the specified scheduling policy.
References: 5.5.2 Headers:
Errors: [ENOSYS] priority scheduling is not supported.
[EINVAL] policy is invalid. Hint: Priority min and max are integer values — you can compute relative
values, for example, half and quarter points in range.
policy | ||
SCHED_ | _FIFO | Run thread until it blocks; |
preempt lower-priority | ||
threads when ready. | ||
SCHED_ | _RR | Like SCHED_FIFO, but sub- |
ject to periodic timeslicing. | ||
SCHED_ | OTHER | Implementation defined (may |
be SCHED_FIFO, SCHED_RR, | ||
or something else). |
9.3.9 Fork handlers
Pthreads provides some new functions to help the new threaded environment to coexist with the traditional process-based UNIX environment. Creation of a child process by copying the full address space, for example, causes problems for threaded applications because the fork call is asynchronous with respect to other threads in the process.
pthread_atfork
int pthread_atfork (
void (*prepare)(void),
void (*parent)(void),
void (*child)(void));
Define "fork handlers" that are run when the process creates a child process. Allows protection of synchronization objects and shared data in the child process (which is otherwise difficult to control).
References: 6.1.1
Headers:
Errors: [ENOMEM] insufficient space to record the handlers.
Hint: All resources needed by child must be protected.
9.3.10
Pthreads provides some new functions, and new versions of old functions, to access ANSI C
flockfile
void flockfile (
FILE *file);
Increase the lock count for a
Although most stdio functions, such as printf and fgets, are thread-safe, you may sometimes find that it is important that a sequence of printf calls, for example, from one thread cannot be separated by calls made from another thread. Also, a few
References: 6.4.1 Headers:
Hint: Use to protect a sequence of
ftrylockfile
int ftrylockfile (
FILE *file);
If the file stream is currently locked by another thread, return a nonzero value. Otherwise, increase the lock count for the file stream, and return the value zero.
References: 6.4.1 Headers:
Hint: Use to protect a sequence
funlockfile
void funlockfile (
FILE *file);
Decrease the lock count for a
References: 6.4.1 Headers:
Hint: Use to protect a sequence of
getc_unlocked
int getc_unlocked (
FILE *file);
Return a single character from the
References: 6.4.2 Headers:
Hint: Replace old calls to getc to retain fastest access.
getchar_unlocked
int getc_unlocked (void);
Return a single character from the
References: 6.4.2 Headers:
Hint: Replace old calls to getchar to retain fastest access.
putc_unlocked
int putc_unlocked (
int c,
FILE *file);