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
RevLine 
[f761f1eb]1/*
[df4ed85]2 * Copyright (c) 2001-2004 Jakub Jermar
[f761f1eb]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
[764c302]29/** @addtogroup genericproc
[b45c443]30 * @{
31 */
32/** @file
33 */
34
[06e1e95]35#ifndef KERN_THREAD_H_
36#define KERN_THREAD_H_
[f761f1eb]37
[b3f8fb7]38#include <synch/waitq.h>
39#include <proc/task.h>
40#include <cpu.h>
[f761f1eb]41#include <synch/rwlock.h>
[016acbe]42#include <adt/btree.h>
[f76fed4]43#include <mm/slab.h>
[b3f8fb7]44#include <arch/cpu.h>
45#include <mm/tlb.h>
[0f250f9]46#include <proc/uarg.h>
[f761f1eb]47
[361635c]48#define THREAD_STACK_SIZE STACK_SIZE
[f761f1eb]49
50extern char *thread_states[];
51
[32fffef0]52/* Thread flags */
[b3f8fb7]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. */
[f761f1eb]56
[05e2a7ad]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 */
[8be8cfa]63SPINLOCK_EXTERN(threads_lock);
[05e2a7ad]64
[016acbe]65extern btree_t threads_btree; /**< B+tree containing all threads. */
[f761f1eb]66
67extern void thread_init(void);
[62b6d17]68extern thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name, bool uncounted);
[f761f1eb]69extern void thread_ready(thread_t *t);
[874621f]70extern void thread_exit(void) __attribute__((noreturn));
[f761f1eb]71
[3fa424a9]72#ifndef thread_create_arch
73extern void thread_create_arch(thread_t *t);
74#endif
[32fffef0]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
[3fa424a9]81
[7f1c620]82extern void thread_sleep(uint32_t sec);
83extern void thread_usleep(uint32_t usec);
[f761f1eb]84
[2cb5e64]85#define thread_join(t) thread_join_timeout((t), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
[7f1c620]86extern int thread_join_timeout(thread_t *t, uint32_t usec, int flags);
[fe19611]87extern void thread_detach(thread_t *t);
88
[f761f1eb]89extern void thread_register_call_me(void (* call_me)(void *), void *call_me_with);
[55ab0f1]90extern void thread_print_list(void);
[266294a9]91extern void thread_destroy(thread_t *t);
[cce6acf]92extern void thread_update_accounting(void);
[016acbe]93extern bool thread_exists(thread_t *t);
[b3f8fb7]94extern void thread_interrupt_sleep(thread_t *t);
[f761f1eb]95
[f76fed4]96/* Fpu context slab cache */
97extern slab_cache_t *fpu_context_slab;
98
[9f52563]99/** Thread syscall prototypes. */
[7f1c620]100unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name);
101unative_t sys_thread_exit(int uspace_status);
[9f52563]102
[f761f1eb]103#endif
[b45c443]104
[764c302]105/** @}
[b45c443]106 */
Note: See TracBrowser for help on using the repository browser.