History log of /fuchsia/zircon/system/ulib/runtime/thread.c
Revision Date Author Comments
# 9dd5b5f5 24-May-2018 Adam Barth <abarth@chromium.org>

[syscalls] Update parameter types and names

This CL updates the parameter types and names for a number of syscalls
to match the Zircon System API rubric. There's more work to do to make
all the syscalls conform to the rubric, but this change is a start.

Change-Id: I218ac5e7e0cbd80a8c69fef7891ad40b78b6b407


# c4b324f3 08-May-2018 Brett Wilson <brettw@chromium.org>

[threads] Make zxr_thread_t opaque.

Previously the definition for zxr_thread_t was in a public header, in
spite of accessor functions that implied it should be internal. The
definition of this struct also depended on C atmoics which prevented
this file's inclusion from any C++ source file.

Making this struct opaque allows the removal of the atomics dependency,
better encapsulation, and inclusion in C++ sources.

This could have been donw with an allocate/deallocate function but the
current uses all allocate the structure by value and this seems to be
appropriate for these uses. Instead, a structure of the correct size is
created for public consumption, enforced by a static assert.

Change-Id: I2c72b8ed990f5e09af2cef93846062fc7eec932f


# a0672e5d 02-May-2018 Roland McGrath <mcgrathr@google.com>

[public][ulib][dev] Add __FALLTHROUGH macro for warning suppression

GCC 7 enables -Wimplicit-fallthrough with -Wextra, so we'll get it.
Clang has it available, so start using it and clean up code accordingly.

The GCC feature will actually recognize some formulaic comments to
suppress the warning. But there's also an explicit syntax, and
C++17 added a standard one. So use that instead, via the new macro
__FALLTHROUGH in <zircon/compiler.h>.

TC-36 #comment Clean up code in preparation for more -Wimplicit-fallthrough

Change-Id: I28309c91c32db1313d52f4255836c5ea687e141f


# d454a8de 19-Jan-2018 cpu <cpu@google.com>

[zircon][system] update thread_start's entry

-Update docs to better explain what are the expectations
of the |entry| function of the syscall
-Update C runtime to use the two args that the syscall
now supports.

Existing test suffice.

Change-Id: I8d212ea2a3f9d036f8e1b30ddc91f6d2522fcdaa


# f3e2126c 12-Sep-2017 Roland McGrath <mcgrathr@google.com>

[zx] Magenta -> Zircon

The Great Renaming is here!

Change-Id: I3229bdeb2a3d0e40fb4db6fec8ca7d971fbffb94


# 0f12b459 20-Jun-2017 Todd Eisenberger <teisenbe@google.com>

[runtime][thread] Remove fallback behavior for DETACHED threads

DETACHED thread exit behavior must be handled by the consumer of
mxr_thread, so trap if we find it was not handled. This also removes
a little previously undocumented behavior of mxr_thread_detatched()
around the return value after the detached thread exits.

Change-Id: I7cb281e04599a0b408361855c099c4b27fb4e59c


# 869aa6a1 14-Jun-2017 Todd Eisenberger <teisenbe@google.com>

[runtime][threads] Rewrite mxr_thread_t join/exit logic

There were previously races when a thread would exit while another
thread was trying to join it. The primary fix is to add an additional
family of states indicating exiting is in progress.

The two big cases that need to be considered are:
- Unjoined thread is exiting while another is joining it.
- Unjoined thread is exiting while another is detaching it.

MG-846 #done

Change-Id: Ib6296d81de76c4d8f10c5a6d88e7159aee04e224


# 0a258603 13-Jun-2017 George Kulakowski <kulakowski@google.com>

[ulib][runtime] Use the MX_ERR_* and MX_OK mx_status_t names

Change-Id: I54b43959017d750c278fbee5a54fd04284fead91


# 9df37598 04-Apr-2017 Josh Conner <joshconner@google.com>

[ulib][runtime] Remove references to 'magic'

Fix comments that refer to the thread 'magic' member, which was
removed.

Change-Id: I456cd005e9b32e98cf1a5eac6134e8871b85d092


# 7304756e 28-Mar-2017 Roland McGrath <mcgrathr@google.com>

[ulib][runtime] Fix death vs join race

It's not safe to access the mxr_thread_t memory after transitioning
to DONE state, because the joiner is free to deallocate the memory.

Change-Id: Ie1fd7301e1cc9cb6b53aeeac2c9b310bee87a333


# 3b894669 31-Mar-2017 George Kulakowski <kulakowski@google.com>

[runtime] Remove obsolete magic thread member

Change-Id: I9239b665849af9f777aed00830cd974b039044a0


# ec674e41 27-Mar-2017 George Kulakowski <kulakowski@google.com>

[runtime][thread] Remove unused mxr_thread_exit

All callers migrated to mxr_thread_exit_unmap_if_detached.

Change-Id: If382dc5a79dc37df5531e6d73bf38e5337a6bdfe


# 52a93d36 24-Feb-2017 Roland McGrath <mcgrathr@google.com>

[ulib][magenta][runtime][musl] Don't use kernel resources for dead threads

A joinable thread that has exited does not need to keep a kernel
thread object alive via its thread handle. Only the memory for
the thread descriptor needs to stick around. By using a futex
rather than an object signal, joins of threads that have already
exited can complete with no system calls.

Change-Id: I2e3eec95e2cf6897ecd3ce31205bc6b018ad40c9


# 01b25b52 23-Feb-2017 Roland McGrath <mcgrathr@google.com>

[ulib][magenta][musl] Stop leaking detached threads' descriptor blocks

This adds a three-in-one vDSO call to roll together mx_vmar_unmap,
mx_handle_close, and mx_thread_exit so a thread can deallocate the
very same stack it's using to call into the vDSO. With this,
detached threads exiting can do their last bit of cleanup so there
are no leaks and no other thread is required to do it later.

MG-549 #done

Change-Id: I4c872aa847582aa18042b8fca3c22f26f6e52e2a


# e55b92da 10-Feb-2017 Brian Swetland <swetland@google.com>

[syscalls] update callers to mx_handle_wait_*() and deprecate

Change-Id: I7b0516007b99d58aee906eac62358625100ee32e


# 6206b7d6 08-Feb-2017 Roland McGrath <mcgrathr@google.com>

[ulib][runtime] Make callers responsible for mxr_thread_t storage

This gets libruntime entirely out of the business of doing
any memory allocation. Its callers are responsible for that.
All libruntime code is purely reentrant.

Change-Id: I8de02266f8950e2d4deca5e66ff60664b780f0d0


# 4b23ec89 24-Jan-2017 George Kulakowski <kulakowski@google.com>

[runtime] Use the _mx_* spellings of magenta functions

Change-Id: Ic9d7e369fa8472bec9a145e93ee4e6eec3b7e6d7


# b50b93c3 03-Jan-2017 George Kulakowski <kulakowski@google.com>

[signals] Remove legacy signal names

Change-Id: I6d4543358a16d16b9b9028ede06af40a632ba31b


# c5cb7076 29-Nov-2016 Todd Eisenberger <teisenbe@google.com>

[vmar][uspace] Migrate the remaining userspace code

This removes the last of the in-repo consumers of the old
VM interface.

Change-Id: I3c7e974802f325b6325254c81b7ba85ebbe9ed2a


# 7006ae17 07-Dec-2016 Roland McGrath <mcgrathr@google.com>

Remove mx_size_t and mx_ssize_t types

mx_ssize_t is no longer used. mx_size_t is superfluous and
can be replaced by the standard C type size_t.

Change-Id: I2137af6f166099d2e8aaca4fab63ff101f2a43ac


# 700a0fa6 21-Nov-2016 Jeff Brown <jeffbrown@google.com>

[libc] Initialize the main thread's thread handle.

Change-Id: I6c226e879430f104edfa495817797fb258699234


# cac54027 01-Nov-2016 Brian Swetland <swetland@google.com>

[syscalls] update vmo_{create,read,write}()

Change-Id: I6b46a48813de4e74767174c2786d04cf414b017a


# ee4544ee 27-Oct-2016 Brian Swetland <swetland@google.com>

[syscalls] mx_thread_create() updated

Change-Id: I843d3a4a15f0f49bb91adc4ebd93ab8983916cb7


# d9525de0 19-Sep-2016 George Kulakowski <kulakowski@google.com>

[runtime][format] Clang format ulib/runtime

Also remove stray trailing semicolon from a do while (0) macro.

Change-Id: Iec181cc42ee4d2b20a15d840b0449624328cd945


# b721f372 15-Sep-2016 George Kulakowski <kulakowski@google.com>

[runtime][musl] Have libc handle thread return values, not runtime

This was originally in runtime, and entirely not moved up into libc when
some other things did. This is test by the existing c11-thread test.

Change-Id: If50a9ac28cf09a8a4eeeb1ada88fb38464fa3aa6


# 6177d2c6 10-Sep-2016 Travis Geiselbrecht <travisg@google.com>

[syscalls][process] drop the magic 0 handle for syscalls that take process handle

This is largely just replacing all cases with mx_process_self()

Change-Id: I5fbe00f814c84537400c6a2eec18e747386ec7db


# a3d7e591 01-Sep-2016 Roland McGrath <mcgrathr@google.com>

[ulib][magenta][runtime][musl] Give system calls _mx_* names, use them in musl

The mx_* name space is not kosher for the standard C library to use
for its own purpose. A conforming standard C program can define its
own functions called mx_* and this must not break the C library.

Give all the system call entry points in the vDSO names starting
with _mx_, with the old mx_ names as aliases. Use only the _mx_
names in runtime and musl.

Change-Id: Id01b57b87c0bb91733e9492159401ff019943822


# accddb9a 31-Aug-2016 Roland McGrath <mcgrathr@google.com>

[runtime][launchpad][userboot] Consolidate stack size computations

This moves the code that knows the ABI requirements for the
stack pointer, and the default user thread stack size, into
a comment place shared by all places that need to know this,
both in kernel and in user mode.

It enforces the ABI-required alignment, rather than assuming that all
stacks are allocated page-aligned. The stacks for additional user
threads created by musl sometimes put the TLS data above the stack.

Change-Id: I606aa10925760a0a3974fd1546e48ca3830f7cd6


# dc1fd725 29-Aug-2016 Brian Swetland <swetland@google.com>

[magenta][syscalls] migrate all syscalls to the new names

If DEPCRECATE_COMPAT_SYSCALLS is defined, flag the compatibility
wrappers with the deprecated attribute.

Enable this in the Magenta build only for now.

Change-Id: I422b1294d9db2e56551eca65dede0e5d83f8b363


# 9e714bf6 26-Aug-2016 Roland McGrath <mcgrathr@google.com>

[kernel] Take second user argument in thread_start system call

Let mx_thread_start specify a second argument register value,
just as mx_process_start can.

Change-Id: I2a995f2a502bf85744ae9def1cda838172350ce3


# e84fbe12 26-Aug-2016 George Kulakowski <kulakowski@google.com>

[runtime][musl][threads] Clean up thread creation failure

- Check for stack allocation failure.
- Deallocate the mxr_thread_t if it is created but doesn't start.

Change-Id: Ife5f6a3d6d1554ec0f5b39fc311bf5a39b6526f2


# c8dc7900 25-Aug-2016 George Kulakowski <kulakowski@google.com>

[runtime][musl] Make callers of mxr_threads allocate stacks

This splits mxr thread creation apart in the same way that the
underlying mx thread syscalls are. It lifts the decision about thread
stack size up to pthreads, where either the attributes or the pthread
defaults can be used, rather than baking this decisions into runtime.

Change-Id: I26323222482e2b7f6fb48ab3fc1b5d58a04ae4e4


# bea41c57 01-Aug-2016 Travis Geiselbrecht <travisg@google.com>

[kernel][magenta] switch thread/process creation syscalls to a two phase api

-In both thread and process creation apis, require user space create the
object first, then start it with additional args
-For threads stack allocation is also moved to user space
-Wire up the process/thread handles to be transferred through to new processes

Change-Id: I43d447c86af1ab3199d8dcf29ff4fe3a384b6e65


# d9a11779 24-Aug-2016 George Kulakowski <kulakowski@google.com>

[runtime] Remove deprecated mxr_process code

The new interface (mxr_processargs) is now used everywhere, so this can
be removed.

Change-Id: I26507ffc8f55f43f4c5de2c17dc74c9ef612dcdf


# 728b9062 23-Aug-2016 George Kulakowski <kulakowski@google.com>

[runtime] Reintroduce mxr_thread_get_handle for debugging APIs

This isn't needed for normal usage, and indeed is just racy (the thread
could detach itself and exit at any time!) in general. But existing test
and debugging code (the testutils library in particular) needs to
carefully hold a thread's hand needs the raw handle.

Change-Id: I6798b66ab2fa5d37e646151e83da845982954c7b


# ffd06b77 22-Aug-2016 George Kulakowski <kulakowski@google.com>

[tls] Reintroduce ELF TLS into musl

Change-Id: I87a7458387aa65b9d1534e51ad5f3abed8587af6


# bf482e62 15-Aug-2016 George Kulakowski <kulakowski@google.com>

[musl][runtime][threads] Move mxr_thread_t callers to C11 threads

Change-Id: Ia8c932f622ae8314f9459246cbba5c64f94da8f5


# 66a201f1 16-Aug-2016 Brian Swetland <swetland@frotz.net>

[system] align license and license banners with Fuchsia

This adjusts the Magenta userspace code to match the prevailing
license in Fuchsia (three-clause BSD), using the same banner
and license text.

Change-Id: I6b6d79435c5dbaa32027888874849e4f47aaa7be


# feb15c6f 14-Jul-2016 Viet-Trung Luu <vtl@google.com>

[magenta][syscalls] Refactor wait-one/wait-many to use a WaitEvent object.

Also make wait-one/wait-many provide the satisfied/satisfiable signals
in a struct (mx_signals_state_t), and add a result_index output argument
to wait-many.

Currently, the WaitEvent object still uses an event_t, but that can be
changed later.

The WaitEvent can pass a context, which is used to transmit the
result_index for wait-many (i.e., the index of the first handle to
cause the wait to be satisfied).

Some of the abstraction (like WaitEvent::Result) is to support future
work on wait sets, etc. (The context also is a uint64_t, to support work
on wait sets.)

Change-Id: I54c517b8627d225da72a23ff5a72be9b3a92065b


# a732ad03 12-Jul-2016 Roland McGrath <mcgrathr@google.com>

[magenta][runtime] Make libmagenta and libruntime freestanding

libruntime should have no dependencies on anything but libmagenta.
The -ffreestanding switch tells the compiler not to generate calls
to standard libc functions (like memcpy or memset). The source code
must avoid explicit dependencies on libc functions too.

Change-Id: I83e259e37084a093ed72dc0ee0f539350f0a48f3


# 937bde71 11-Jul-2016 Brian Swetland <swetland@google.com>

[syscalls][api] rename _magenta_*() to mx_*()

The _magenta_ prefix is pretty unwieldy.
This change simplifies that a bit.

This was done mechanically, and boots, runs, and passes tests
on qemu arm64, amd64, and NUC.

Change-Id: I8eb07db6ed6f4b8cac96344cc4ad65ce3f85f917


# 9f79ef6c 07-Jul-2016 Travis Geiselbrecht <travisg@google.com>

[system][threads] switch most users of _magenta_thread_create to mxr_ equivalent

This will make it somewhat easier to work with the underlying syscalls.

Change-Id: I39522f4a84d9841b654682a11c1eaa391cf12aa0


# 4ebbc5b1 15-Jun-2016 Brian Swetland <swetland@google.com>

[system] clang-format all of userspace

Change-Id: I6bb6a9187a4af83ca5c0656f05d89aa3a09fa5fa


# 53b9e1c8 15-Jun-2016 The Fuchsia Authors <authors@fuchsia.local>

[magenta] Initial commit