2002-07-09 16:24:59 +04:00
|
|
|
/*
|
2004-02-23 06:13:54 +03:00
|
|
|
** Copyright 2002-2004, The OpenBeOS Team. All rights reserved.
|
|
|
|
** Distributed under the terms of the OpenBeOS License.
|
|
|
|
**
|
2002-07-09 16:24:59 +04:00
|
|
|
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
|
|
|
** Distributed under the terms of the NewOS License.
|
|
|
|
*/
|
|
|
|
#ifndef _THREAD_H
|
|
|
|
#define _THREAD_H
|
|
|
|
|
|
|
|
|
2003-01-27 05:54:21 +03:00
|
|
|
#include <OS.h>
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <thread_types.h>
|
|
|
|
#include <arch/thread.h>
|
|
|
|
|
2002-10-23 21:31:10 +04:00
|
|
|
|
2004-03-16 05:40:03 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2003-01-27 05:54:21 +03:00
|
|
|
void scheduler_reschedule(void);
|
|
|
|
void start_scheduler(void);
|
2002-10-23 21:31:10 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
void thread_enqueue(struct thread *t, struct thread_queue *q);
|
|
|
|
struct thread *thread_lookat_queue(struct thread_queue *q);
|
|
|
|
struct thread *thread_dequeue(struct thread_queue *q);
|
|
|
|
struct thread *thread_dequeue_id(struct thread_queue *q, thread_id thr_id);
|
2003-01-27 05:54:21 +03:00
|
|
|
|
|
|
|
void scheduler_enqueue_in_run_queue(struct thread *thread);
|
|
|
|
void scheduler_remove_from_run_queue(struct thread *thread);
|
|
|
|
|
2002-10-05 23:44:27 +04:00
|
|
|
void thread_atkernel_entry(void);
|
|
|
|
// called when the thread enters the kernel on behalf of the thread
|
2002-07-09 16:24:59 +04:00
|
|
|
void thread_atkernel_exit(void);
|
|
|
|
|
2004-03-17 18:27:19 +03:00
|
|
|
status_t thread_init(kernel_args *ka);
|
|
|
|
status_t thread_per_cpu_init(int32 cpu_num);
|
2002-10-26 05:11:15 +04:00
|
|
|
void thread_exit(void);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
#define thread_get_current_thread arch_thread_get_current_thread
|
|
|
|
|
|
|
|
struct thread *thread_get_thread_struct(thread_id id);
|
2002-08-16 17:14:29 +04:00
|
|
|
struct thread *thread_get_thread_struct_locked(thread_id id);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-10-05 05:17:28 +04:00
|
|
|
static thread_id thread_get_current_thread_id(void);
|
|
|
|
static inline thread_id
|
|
|
|
thread_get_current_thread_id(void)
|
|
|
|
{
|
|
|
|
struct thread *t = thread_get_current_thread();
|
|
|
|
return t ? t->id : 0;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
2002-10-05 05:17:28 +04:00
|
|
|
|
2003-01-27 05:54:21 +03:00
|
|
|
thread_id spawn_kernel_thread_etc(thread_func, const char *name, int32 priority, void *args, team_id team);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// used in syscalls.c
|
2004-03-03 03:52:47 +03:00
|
|
|
status_t _user_set_thread_priority(thread_id thread, int32 newPriority);
|
2004-04-07 01:30:06 +04:00
|
|
|
status_t _user_rename_thread(thread_id thread, const char *name);
|
2004-03-03 03:52:47 +03:00
|
|
|
status_t _user_suspend_thread(thread_id thread);
|
|
|
|
status_t _user_resume_thread(thread_id thread);
|
2004-05-24 16:12:58 +04:00
|
|
|
status_t _user_rename_thread(thread_id thread, const char *name);
|
2004-09-01 19:47:47 +04:00
|
|
|
thread_id _user_spawn_thread(thread_entry_func entry, const char *name, int32 priority, void *arg1, void *arg2);
|
2004-03-03 03:52:47 +03:00
|
|
|
status_t _user_wait_for_thread(thread_id id, status_t *_returnCode);
|
|
|
|
status_t _user_snooze_etc(bigtime_t timeout, int timebase, uint32 flags);
|
|
|
|
status_t _user_kill_thread(thread_id thread);
|
|
|
|
void _user_exit_thread(status_t return_value);
|
|
|
|
bool _user_has_data(thread_id thread);
|
|
|
|
status_t _user_send_data(thread_id thread, int32 code, const void *buffer, size_t buffer_size);
|
|
|
|
status_t _user_receive_data(thread_id *_sender, void *buffer, size_t buffer_size);
|
|
|
|
thread_id _user_find_thread(const char *name);
|
|
|
|
status_t _user_get_thread_info(thread_id id, thread_info *info);
|
|
|
|
status_t _user_get_next_thread_info(team_id team, int32 *cookie, thread_info *info);
|
|
|
|
|
|
|
|
// ToDo: these don't belong here
|
|
|
|
int _user_getrlimit(int resource, struct rlimit * rlp);
|
|
|
|
int _user_setrlimit(int resource, const struct rlimit * rlp);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
#if 1
|
|
|
|
// XXX remove later
|
|
|
|
int thread_test(void);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _THREAD_H */
|