source: mainline/kernel/generic/src/main/uinit.c@ 40eab9f

topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 40eab9f was 1871118, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 2 years ago

Make thread_t reference counted

This simplifies interaction between various locks and thread
lifespan, which simplifies things. For example, threads_lock can
now simply be a mutex protecting the global it was made for, and
nothing more.

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 * Copyright (c) 2005 Jakub Jermar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup kernel_generic
30 * @{
31 */
32
33/**
34 * @file
35 * @brief Userspace bootstrap thread.
36 *
37 * This file contains uinit kernel thread wich is used to start every
38 * userspace thread including threads created by SYS_THREAD_CREATE syscall.
39 *
40 * @see SYS_THREAD_CREATE
41 */
42
43#include <main/uinit.h>
44#include <typedefs.h>
45#include <proc/thread.h>
46#include <userspace.h>
47#include <stdlib.h>
48#include <arch.h>
49#include <udebug/udebug.h>
50
51/** Thread used to bring up userspace thread.
52 *
53 * @param arg Pointer to structure containing userspace entry and stack
54 * addresses.
55 */
56void uinit(void *arg)
57{
58#ifdef CONFIG_UDEBUG
59 udebug_stoppable_end();
60#endif
61
62 uspace_arg_t *uarg = arg;
63 uspace_arg_t local_uarg;
64
65 local_uarg.uspace_entry = uarg->uspace_entry;
66 local_uarg.uspace_stack = uarg->uspace_stack;
67 local_uarg.uspace_stack_size = uarg->uspace_stack_size;
68 local_uarg.uspace_uarg = uarg->uspace_uarg;
69 local_uarg.uspace_thread_function = USPACE_NULL;
70 local_uarg.uspace_thread_arg = USPACE_NULL;
71
72 free(uarg);
73
74 userspace(&local_uarg);
75}
76
77/** @}
78 */
Note: See TracBrowser for help on using the repository browser.