source: mainline/kernel/generic/include/proc/thread.h@ 3802fcd

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 3802fcd was 8be8cfa, checked in by Martin Decky <martin@…>, 18 years ago

spinlock extern declaration macro

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 * Copyright (c) 2001-2004 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 genericproc
30 * @{
31 */
32/** @file
33 */
34
35#ifndef KERN_THREAD_H_
36#define KERN_THREAD_H_
37
38#include <synch/waitq.h>
39#include <proc/task.h>
40#include <cpu.h>
41#include <synch/rwlock.h>
42#include <adt/btree.h>
43#include <mm/slab.h>
44#include <arch/cpu.h>
45#include <mm/tlb.h>
46#include <proc/uarg.h>
47
48#define THREAD_STACK_SIZE STACK_SIZE
49
50extern char *thread_states[];
51
52/* Thread flags */
53#define THREAD_FLAG_WIRED (1 << 0) /**< Thread cannot be migrated to another CPU. */
54#define THREAD_FLAG_STOLEN (1 << 1) /**< Thread was migrated to another CPU and has not run yet. */
55#define THREAD_FLAG_USPACE (1 << 2) /**< Thread executes in userspace. */
56
57/** Thread list lock.
58 *
59 * This lock protects all link_t structures chained in threads_head.
60 * Must be acquired before T.lock for each T of type thread_t.
61 *
62 */
63SPINLOCK_EXTERN(threads_lock);
64
65extern btree_t threads_btree; /**< B+tree containing all threads. */
66
67extern void thread_init(void);
68extern thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name, bool uncounted);
69extern void thread_ready(thread_t *t);
70extern void thread_exit(void) __attribute__((noreturn));
71
72#ifndef thread_create_arch
73extern void thread_create_arch(thread_t *t);
74#endif
75#ifndef thr_constructor_arch
76extern void thr_constructor_arch(thread_t *t);
77#endif
78#ifndef thr_destructor_arch
79extern void thr_destructor_arch(thread_t *t);
80#endif
81
82extern void thread_sleep(uint32_t sec);
83extern void thread_usleep(uint32_t usec);
84
85#define thread_join(t) thread_join_timeout((t), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
86extern int thread_join_timeout(thread_t *t, uint32_t usec, int flags);
87extern void thread_detach(thread_t *t);
88
89extern void thread_register_call_me(void (* call_me)(void *), void *call_me_with);
90extern void thread_print_list(void);
91extern void thread_destroy(thread_t *t);
92extern void thread_update_accounting(void);
93extern bool thread_exists(thread_t *t);
94extern void thread_interrupt_sleep(thread_t *t);
95
96/* Fpu context slab cache */
97extern slab_cache_t *fpu_context_slab;
98
99/** Thread syscall prototypes. */
100unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name);
101unative_t sys_thread_exit(int uspace_status);
102
103#endif
104
105/** @}
106 */
Note: See TracBrowser for help on using the repository browser.