NAME | SYNOPSIS | FEATURES | DESCRIPTION | RETURN VALUE | ERRORS | RESTRICTIONS | ATTRIBUTES | SEE ALSO
#include <exec/chExec.h>int threadContext(KnCap *actorcap, KnThreadLid threadli, unsigned int type, void *oldcontext, void *newcontext);
CORE
The threadContext system call gets and/or sets the execution context of the thread whose local identifier is threadli, in the actor whose capability is given by actorcap. If actorcap is K_MYACTOR, the thread is a thread of the current actor. In this case, if threadli is K_MYSELF, the current thread is used.
The type parameter selects the component of the execution context which is affected. If type is K_CURRCTX, the thread's hardware context is affected. In this case, oldcontext and newcontext must be pointers to KnThreadCtx structures defined in the exec/chThCtx_f.h header file. The fields of this structure are machine-dependent. A thread's hardware context is defined as the set of general--purpose machine register values (including stack pointer, program counter, and so on) put on the stack when an initial (non-nested) trap, exception, or preemption occurred. Any subsequent nested events (in the case of a trap or exception) have no effect on the thread's hardware context as accessed by K_CURRCTX.
If type is K_SUPPRIV, the thread's supervisor software register context is affected (see threadLoadR(2K)). In this case, oldcontext and newcontext must be pointers to an array of void* whose size is K_NBPRIVDATA.
If type is K_USERPRIV, the thread's user software register context is affected (see threadLoadR(2K)). In this case, oldcontext and newcontext must be pointers to an array of void* whose size is K_NBPRIVDATA. This type is valid only for threads of user privilege.
If type is K_SOFTCTX, the thread's software register context is affected (see threadLoadR(2K)). In this case, oldcontext and newcontext must be pointers to KnThreadSoftCtx structures, whose members are the following:
long userReg ; /* user privilege register */ long supReg ; /* supervisor privilege register */Note that the caller thread must be a supervisor thread (see threadCreate(2K)) or must belong to a system actor (see actorCreate(2K)) in order to modify the supReg value.
In either case, the thread's current execution context is copied into the structure pointed to by oldcontext (if not NULL) in the client address space. The thread's new context will be taken from the structure pointed to by newcontext (if not NULL).
Upon successful completion a value of 0 is returned. Otherwise, a negative error code is returned.
actorcap is an inconsistent actor capability, or threadli is not a valid thread identifier in the specified actor.
actorcap does not specify a reachable actor.
Some of the data provided is out of the current actor's address space.
The caller thread is not allowed to perform the operation.
The hardware execution context of the target thread is not available.
The target actor and the current actor must be located on the same site.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
NAME | SYNOPSIS | FEATURES | DESCRIPTION | RETURN VALUE | ERRORS | RESTRICTIONS | ATTRIBUTES | SEE ALSO