Skip to content

Commit

Permalink
unified/doc: Minor updates to thread sections in Kernel Primer
Browse files Browse the repository at this point in the history
Change-Id: Id090413b51bf194b358c8b25e860af01368774a0
Signed-off-by: Allan Stephens <[email protected]>
  • Loading branch information
ajstephens authored and benwrs committed Oct 11, 2016
1 parent f0d6c03 commit da912ba
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 43 deletions.
41 changes: 5 additions & 36 deletions doc/kernel_v2/threads/lifecycle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ A thread has the following key properties:
* An **entry point function**, which is invoked when the thread is started.
Up to 3 **argument values** can be passed to this function.

* An **abort function**, which is invoked when the thread is completely
finished executing. (See "Thread Aborting".)

* A **scheduling priority**, which instructs the kernel's scheduler how to
allocate CPU time to the thread. (See "Thread Scheduling".)

Expand Down Expand Up @@ -85,19 +82,6 @@ owned by an aborted thread.
The kernel does not currently make any claims regarding an application's
ability to respawn a thread that aborts.

Abort Handler
=============

A thread's **abort handler** is automatically invoked when the thread
terminates or aborts. The abort handler is a function that takes no arguments
and returns ``void``.

If the thread's abort handler is ``NULL``, no action is taken;
otherwise, the abort handler is executed using the kernel's system workqueue.

The abort handler can be used to record information about the thread
or to assist in reclaiming resources owned by the thread.

Thread Suspension
=================

Expand Down Expand Up @@ -207,23 +191,8 @@ APIs

The following thread APIs are are provided by :file:`kernel.h`:

:cpp:func:`k_thread_spawn()`, :cpp:func:`k_thread_spawn_config()`
Spawn a new thread.

:cpp:func:`k_thread_spawn_cancel()`
[NON-EXISTENT] Cancel spawning of a new thread, if not already started.

:cpp:func:`thread_entry_set()`
[NON-EXISTENT] Sets a thread's entry point.

:cpp:func:`thread_suspend()`
[NON-EXISTENT] Suspend execution of a thread.

:cpp:func:`thread_resume()`
[NON-EXISTENT] Resume execution of a thread.

:cpp:func:`k_thread_abort()`
Abort execution of a thread.

:cpp:func:`thread_abort_handler_set()`
Install a thread's abort handler.
* :cpp:func:`k_thread_spawn()`
* :cpp:func:`k_thread_cancel()`
* :cpp:func:`k_thread_abort()`
* :cpp:func:`k_thread_suspend()`
* :cpp:func:`k_thread_resume()`
30 changes: 23 additions & 7 deletions doc/kernel_v2/threads/scheduling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,36 @@ becomes the current thread, its non-preemptible status is maintained.
Locking out the scheduler is a more efficient way for a preemptible thread
to inhibit preemption than changing its priority level to a negative value.
.. _thread_sleeping:

Thread Sleeping
===============

A thread can call :cpp:func:`k_sleep()` to delay its processing
for a specified time period. During the time the thread is sleeping
the CPU is relinquished to allow other ready threads to execute.
Once the specified delay has elapsed the thread becomes ready
and is eligible to be scheduled once again.

A sleeping thread can be woken up prematurely by another thread using
:cpp:func:`k_wakeup()`. This technique can sometimes be used
to permit the secondary thread to signal the sleeping thread
that something has occurred *without* requiring the threads
to define a kernel synchronization object, such as a semaphore.
Waking up a thread that is not sleeping is allowed, but has no effect.

.. _busy_waiting:

Busy Waiting
============

A thread can call :cpp:func:`k_busy_wait()` to perform a ``busy wait``
that delays its processing for a specified time period
*without* relinquishing the CPU to another ready thread.

A busy wait is typically used when the required delay is too short
to warrant having the scheduler context switch to another thread
and then back again.
A busy wait is typically used instead of thread sleeping
when the required delay is too short to warrant having the scheduler
context switch from the current thread to another thread and then back again.

Suggested Uses
**************
Expand Down Expand Up @@ -213,12 +233,8 @@ APIs
The following thread scheduling-related APIs are provided by :file:`kernel.h`:

* :cpp:func:`k_current_get()`
* :cpp:func:`thread_priority_get()` [NON-EXISTENT]
* :cpp:func:`thread_priority_set()` [NON-EXISTENT]
* :cpp:func:`k_yield()`
* :cpp:func:`k_sleep()`
* :cpp:func:`k_wakeup()`
* :cpp:func:`k_busy_wait()`
* :cpp:func:`k_sched_time_slice_set()`
* :cpp:func:`k_workload_get()` [NON-EXISTENT]
* :cpp:func:`k_workload_time_slice_set()` [NON-EXISTENT]

0 comments on commit da912ba

Please sign in to comment.