Removed the "path" field in the team structure. Renamed "ioctx" to "io_context".

Added a "page_faults_allowed" field in the thread structure.
Clean up.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2138 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2002-12-03 14:05:21 +00:00
parent da4ffe5d0b
commit c5cf4e87b6
+23 -58
View File
@@ -1,21 +1,11 @@
/* Thread definition and structures
**
** Distributed under the terms of the OpenBeOS License.
*/
#ifndef _KERNEL_THREAD_TYPES_H #ifndef _KERNEL_THREAD_TYPES_H
#define _KERNEL_THREAD_TYPES_H #define _KERNEL_THREAD_TYPES_H
/**
* @file kernel/thread_types.h
* @brief Definitions, structures and functions for threads.
*/
/**
* @defgroup Kernel_Threads Threads
* @ingroup OpenBeOS_Kernel
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <stage2.h> #include <stage2.h>
#include <ktypes.h> #include <ktypes.h>
#include <cbuf.h> #include <cbuf.h>
@@ -25,6 +15,7 @@ extern "C" {
#include <timer.h> #include <timer.h>
#include <arch/thread_struct.h> #include <arch/thread_struct.h>
extern spinlock thread_spinlock; extern spinlock thread_spinlock;
#define GRAB_THREAD_LOCK() acquire_spinlock(&thread_spinlock) #define GRAB_THREAD_LOCK() acquire_spinlock(&thread_spinlock)
#define RELEASE_THREAD_LOCK() release_spinlock(&thread_spinlock) #define RELEASE_THREAD_LOCK() release_spinlock(&thread_spinlock)
@@ -37,16 +28,16 @@ extern spinlock team_spinlock;
#define GRAB_TEAM_LOCK() acquire_spinlock(&team_spinlock) #define GRAB_TEAM_LOCK() acquire_spinlock(&team_spinlock)
#define RELEASE_TEAM_LOCK() release_spinlock(&team_spinlock) #define RELEASE_TEAM_LOCK() release_spinlock(&team_spinlock)
enum { enum additional_thread_state {
// THREAD_STATE_READY = 0, // ready to run // THREAD_STATE_READY = 0, // ready to run
// THREAD_STATE_RUNNING, // running right now somewhere // THREAD_STATE_RUNNING, // running right now somewhere
// THREAD_STATE_WAITING, // blocked on something // THREAD_STATE_WAITING, // blocked on something
// THREAD_STATE_SUSPENDED, // suspended, not in queue // THREAD_STATE_SUSPENDED, // suspended, not in queue
THREAD_STATE_FREE_ON_RESCHED=7, // free the thread structure upon reschedule THREAD_STATE_FREE_ON_RESCHED = 7, // free the thread structure upon reschedule
// THREAD_STATE_BIRTH // thread is being created // THREAD_STATE_BIRTH // thread is being created
}; };
enum { enum team_state {
TEAM_STATE_NORMAL, // normal state TEAM_STATE_NORMAL, // normal state
TEAM_STATE_BIRTH, // being contructed TEAM_STATE_BIRTH, // being contructed
TEAM_STATE_DEATH // being killed TEAM_STATE_DEATH // being killed
@@ -57,35 +48,16 @@ enum {
#define THREAD_RETURN_INTERRUPTED 0x2 #define THREAD_RETURN_INTERRUPTED 0x2
/**
* The team structure; equivalent to a common process.
* @note This is available only within the kernel.
*/
struct team { struct team {
/** Pointer to next team structure */ struct team *next; /* next team in the hash */
struct team *next;
/** The team_id for this process. */
team_id id; team_id id;
/** name of the process
* @note The maximum length is current SYS_MAX_OS_NAME_LEN chars.
*/
char name[SYS_MAX_OS_NAME_LEN]; char name[SYS_MAX_OS_NAME_LEN];
/** How many threads does this process have? */ int num_threads; /* number of threads in this team */
int num_threads; int state; /* current team state, see above */
/** Current state of the process. */
int state;
/** Signals pending for the process? */
int pending_signals; int pending_signals;
/** Pointer to the I/O context for this process. void *io_context;
* @note see fd.h for definition of ioctx sem_id death_sem; /* semaphore to wait on for dying threads */
*/ aspace_id _aspace_id; /* address space pointer */
void *ioctx;
/** Path ??? */
char path[SYS_MAX_PATH_LEN];
/** Semaphore to wait on for dying threads */
sem_id death_sem;
/** Our address space pointer */
aspace_id _aspace_id;
vm_address_space *aspace; vm_address_space *aspace;
vm_address_space *kaspace; vm_address_space *kaspace;
addr user_env_base; addr user_env_base;
@@ -111,12 +83,14 @@ struct thread {
struct sigaction sig_action[32]; struct sigaction sig_action[32];
bool in_kernel; bool in_kernel;
sem_id sem_blocking; sem_id sem_blocking;
int sem_count; int sem_count;
int sem_acquire_count; int sem_acquire_count;
int sem_deleted_retcode; int sem_deleted_retcode;
int sem_errcode; int sem_errcode;
int sem_flags; int sem_flags;
struct { struct {
sem_id write_sem; sem_id write_sem;
sem_id read_sem; sem_id read_sem;
@@ -125,13 +99,19 @@ struct thread {
size_t size; size_t size;
cbuf *buffer; cbuf *buffer;
} msg; } msg;
addr fault_handler; addr fault_handler;
int32 page_faults_allowed;
/* this field may only stay in debug builds in the future*/
addr entry; addr entry;
void *args; void *args;
struct team *team; struct team *team;
status_t return_code; status_t return_code;
sem_id return_code_sem; sem_id return_code_sem;
int return_flags; int return_flags;
// stack
region_id kernel_stack_region_id; region_id kernel_stack_region_id;
addr kernel_stack_base; addr kernel_stack_base;
region_id user_stack_region_id; region_id user_stack_region_id;
@@ -150,19 +130,4 @@ struct thread_queue {
struct thread *tail; struct thread *tail;
}; };
#if 1
/**
* Test routine for threads.
* @note This function will be removed as is intended for test and
* development purposes only.
*/
int thread_test(void);
#endif
#ifdef __cplusplus
}
#endif
/** @} */
#endif /* _KERNEL_THREAD_TYPES_H */ #endif /* _KERNEL_THREAD_TYPES_H */