Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 62 additions & 3 deletions kernel/syscalls/threads.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,70 @@ Suspends thread execution for number of microseconds defined by `us`.
## `syscalls_threadGetInfo` (`syscalls_threadinfo`)

````C
GETFROMSTACK(ustack, int, n, 0);
GETFROMSTACK(ustack, threadinfo_t *, info, 1);
GETFROMSTACK(ustack, int, tid, 0);
GETFROMSTACK(ustack, unsigned int, flags, 1);
GETFROMSTACK(ustack, int, n, 2);
GETFROMSTACK(ustack, threadinfo_t *, info, 3);
````

Returns thread information `info` for thread given by `n`.
Returns attributes of thread referred to by `tid`. Thread attributes to retrieve
are specified in `flags` and outputted to `info`.

`tid` can contain a special value `PH_THREADINFO_THREADS_ALL` which will make
`threadsinfo` target all, present at the time of invocation, threads in the system.
In this mode, `info` is treated as an array of `threadinfo_t`, with the number of
elements specified in `n`. Otherwise, `n` must be set to 1.

`flags` is a bitmask, with following flags available:

- `PH_THREADINFO_TID`

Returns thread's ID for queried thread in `info.tid`.

- `PH_THREADINFO_PRIO`

Returns priority for queried thread in `info.priority`.

- `PH_THREADINFO_STATE`

Returns current state for queried thread in `info.state`.

- `PH_THREADINFO_LOAD`

Returns current load for queried thread in `info.load`.

- `PH_THREADINFO_CPUTIME`

Returns time spent executing on a CPU for queried thread in `info.cpuTime`.

- `PH_THREADINFO_WAITING`

Returns time spent waiting for queried thread in `info.wait`.

- `PH_THREADINFO_NAME`

Returns thread's name in `info.name`.

The actual length of thread's name can be arbitrarily long, however, the returned
name is capped at `sizeof(info.name)`.

- `PH_THREADINFO_VMEM`

Returns the amount of mapped virtual memory in queried thread in `info.vmem`.

- `PH_THREADINFO_PPID`

Returns parent PID for queried thread in `info.ppid`.

- `PH_THREADINFO_ALL`

Returns all queryable attributes

- `PH_THREADINFO_OPT_THREADCOUNT`

Causes `threadsinfo` to ignore arguments `n` and `info`, as well as rest of
`flags` bits and returns amount of present threads in the system at the time
of invocation in `threadsinfo` return value.
Comment on lines +99 to +101

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This paragraph has some grammatical items that make it a bit hard to read. I'd suggest rephrasing it for clarity and correctness.

Suggested change
Causes `threadsinfo` to ignore arguments `n` and `info`, as well as rest of
`flags` bits and returns amount of present threads in the system at the time
of invocation in `threadsinfo` return value.
Causes `threadsinfo` to ignore the `n` and `info` arguments, as well as the rest of
the `flags` bits. It then returns the number of threads present in the system at the time
of invocation as its return value.


## `syscalls_threadGetID` (`syscalls_gettid`)

Expand Down