Thread functions.
More...
|
syscall | chprio (tid_typ tid, int newprio) |
|
tid_typ | create (void *procaddr, uint ssize, int priority, const char *name, int nargs,...) |
|
tid_typ | getfirst (qid_typ q) |
|
tid_typ | getlast (qid_typ q) |
|
tid_typ | getitem (tid_typ tid) |
|
syscall | getprio (tid_typ tid) |
|
tid_typ | gettid (void) |
|
int | insert (tid_typ tid, qid_typ q, int key) |
|
int | insertd (tid_typ tid, qid_typ q, int key) |
|
syscall | kill (tid_typ tid) |
|
qid_typ | queinit (void) |
|
tid_typ | enqueue (tid_typ tid, qid_typ q) |
|
tid_typ | dequeue (qid_typ q) |
|
int | ready (tid_typ tid, bool resch, uint core) |
|
message | receive (void) |
|
message | recvclr (void) |
|
message | recvtime (int maxwait) |
|
int | resched (void) |
|
syscall | resume (tid_typ tid) |
|
syscall | send (tid_typ tid, message msg) |
|
syscall | sleep (uint ms) |
|
syscall | suspend (tid_typ tid) |
|
syscall | unsleep (tid_typ tid) |
|
void | userret (void) |
|
syscall | yield (void) |
|
Thread functions.
syscall chprio |
( |
tid_typ |
tid, |
|
|
int |
newprio |
|
) |
| |
Change the scheduling priority of a thread
- Parameters
-
tid | target thread |
newprio | new priority |
- Returns
- old priority of thread
tid_typ create |
( |
void * |
procaddr, |
|
|
uint |
ssize, |
|
|
int |
priority, |
|
|
const char * |
name, |
|
|
int |
nargs, |
|
|
|
... |
|
) |
| |
Create a thread to start running a procedure.
- Parameters
-
procaddr | procedure address |
ssize | stack size in bytes |
priority | thread priority (0 is lowest priority) |
name | name of the thread, used for debugging |
nargs | number of arguments that follow |
... | arguments to pass to thread procedure |
- Returns
- the new thread's thread id, or ::SYSERR if a new thread could not be created (not enough memory or thread entries).
tid_typ dequeue |
( |
qid_typ |
q | ) |
|
Remove and return the first thread on a list
- Parameters
-
- Returns
- thread id of removed thread, or EMPTY
tid_typ enqueue |
( |
tid_typ |
tid, |
|
|
qid_typ |
q |
|
) |
| |
Insert a thread at the tail of a queue
- Parameters
-
tid | thread ID to enqueue |
q | target queue |
- Returns
- thread id of enqueued thread
tid_typ getfirst |
( |
qid_typ |
q | ) |
|
Remove a thread from front of queue
- Parameters
-
- Returns
- thread ID of removed thread
tid_typ getitem |
( |
tid_typ |
tid | ) |
|
Remove a thread from anywhere in a queue
- Parameters
-
- Returns
- thread ID of removed thread
tid_typ getlast |
( |
qid_typ |
q | ) |
|
Remove a thread from end of queue
- Parameters
-
- Returns
- thread ID of removed thread
syscall getprio |
( |
tid_typ |
tid | ) |
|
Return the scheduling priority of a thread
- Parameters
-
- Returns
- priority of thread on success, SYSERR on failure
Get the thread id of currently executing thread.
- Returns
- thread id of the currently running thread
int insert |
( |
tid_typ |
tid, |
|
|
qid_typ |
q, |
|
|
int |
key |
|
) |
| |
Insert a thread into a queue in descending key order.
- Parameters
-
tid | thread ID to insert |
q | target queue |
key | sorting key |
- Returns
- OK
int insertd |
( |
tid_typ |
tid, |
|
|
qid_typ |
q, |
|
|
int |
key |
|
) |
| |
Insert a thread in delta queue in ascending order
- Parameters
-
tid | thread id to insert |
q | queue in which thread should be inserted |
key | delta key |
- Returns
- OK
syscall kill |
( |
tid_typ |
tid | ) |
|
Kill a thread and remove it from the system
- Parameters
-
- Returns
- OK on success, SYSERR otherwise
Initialize a new queue in the global thread queue table
- Returns
- newly allocated queue ID or SYSERR
< next available quetab entry
int ready |
( |
tid_typ |
tid, |
|
|
bool |
resch, |
|
|
uint |
core |
|
) |
| |
Make a thread eligible for CPU service.
- Parameters
-
tid | target thread |
resch | if RESCHED_YES, reschedules |
- Returns
- OK if thread has been added to readylist, else SYSERR
receive - wait for a message and return it
- Returns
- message
Clear messages, return waiting message (if any)
- Returns
- msg if available, NOMSG if no message
message recvtime |
( |
int |
maxwait | ) |
|
wait to receive a message or timeout and return result
- Parameters
-
maxwait | ticks to wait before timeout |
- Returns
- msg if becomes available, TIMEOUT if no message
Reschedule processor to highest priority ready thread. Upon entry, thrcurrent gives current thread id. Threadtab[thrcurrent].pstate gives correct NEXT state for current thread if other than THRREADY.
- Returns
- OK when the thread is context switched back
syscall resume |
( |
tid_typ |
tid | ) |
|
Unsuspend a thread, making it ready
- Parameters
-
- Returns
- priority
syscall send |
( |
tid_typ |
tid, |
|
|
message |
msg |
|
) |
| |
Send a message to another thread
- Parameters
-
tid | thread id of recipient |
msg | contents of message |
- Returns
- OK on success, SYSERR on failure
Yields the processor for the specified number of milliseconds, allowing other threads to be scheduled.
- Parameters
-
ms | number of milliseconds to sleep |
- Returns
- If successful, the thread will sleep for the specified number of milliseconds, then return ::OK. Otherwise, ::SYSERR will be returned. If a system timer is not supported, ::SYSERR will always returned.
syscall suspend |
( |
tid_typ |
tid | ) |
|
Suspend a thread, placing it in hibernation
- Parameters
-
- Returns
- priority or SYSERR
syscall unsleep |
( |
tid_typ |
tid | ) |
|
Remove thread from the sleep queue prematurely
- Parameters
-
- Returns
- OK if thread removed, else SYSERR
Entered when a thread exits by return.
Yield processor.
- Returns
- OK when the thread is context switched back