Subversion Repositories HelenOS-historic

Rev

Rev 1062 | Rev 1078 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1062 Rev 1066
Line 41... Line 41...
41
#include <adt/list.h>
41
#include <adt/list.h>
42
#include <mm/slab.h>
42
#include <mm/slab.h>
43
 
43
 
44
#define THREAD_STACK_SIZE   STACK_SIZE
44
#define THREAD_STACK_SIZE   STACK_SIZE
45
 
45
 
46
#define THREAD_USER_STACK   1
-
 
47
 
-
 
48
enum state {
46
enum state {
49
    Invalid,    /**< It is an error, if thread is found in this state. */
47
    Invalid,    /**< It is an error, if thread is found in this state. */
50
    Running,    /**< State of a thread that is currently executing on some CPU. */
48
    Running,    /**< State of a thread that is currently executing on some CPU. */
51
    Sleeping,   /**< Thread in this state is waiting for an event. */
49
    Sleeping,   /**< Thread in this state is waiting for an event. */
52
    Ready,      /**< State of threads in a run queue. */
50
    Ready,      /**< State of threads in a run queue. */
Line 57... Line 55...
57
extern char *thread_states[];
55
extern char *thread_states[];
58
 
56
 
59
#define X_WIRED     (1<<0)
57
#define X_WIRED     (1<<0)
60
#define X_STOLEN    (1<<1)
58
#define X_STOLEN    (1<<1)
61
 
59
 
-
 
60
#define THREAD_NAME_BUFLEN  20
-
 
61
 
62
/** Thread structure. There is one per thread. */
62
/** Thread structure. There is one per thread. */
63
struct thread {
63
struct thread {
64
    char *name;
-
 
65
   
-
 
66
    link_t rq_link;             /**< Run queue link. */
64
    link_t rq_link;             /**< Run queue link. */
67
    link_t wq_link;             /**< Wait queue link. */
65
    link_t wq_link;             /**< Wait queue link. */
68
    link_t th_link;             /**< Links to threads within containing task. */
66
    link_t th_link;             /**< Links to threads within containing task. */
69
    link_t threads_link;            /**< Link to the list of all threads. */
67
    link_t threads_link;            /**< Link to the list of all threads. */
70
   
68
   
Line 74... Line 72...
74
     * Must be acquired before T.lock for each T of type task_t.
72
     * Must be acquired before T.lock for each T of type task_t.
75
     *
73
     *
76
     */
74
     */
77
    SPINLOCK_DECLARE(lock);
75
    SPINLOCK_DECLARE(lock);
78
 
76
 
-
 
77
    char name[THREAD_NAME_BUFLEN];
-
 
78
 
79
    void (* thread_code)(void *);       /**< Function implementing the thread. */
79
    void (* thread_code)(void *);       /**< Function implementing the thread. */
80
    void *thread_arg;           /**< Argument passed to thread_code() function. */
80
    void *thread_arg;           /**< Argument passed to thread_code() function. */
81
 
81
 
82
    context_t saved_context;        /**< From here, the stored context is restored when the thread is scheduled. */
82
    context_t saved_context;        /**< From here, the stored context is restored when the thread is scheduled. */
83
    context_t sleep_timeout_context;    /**< From here, the stored failover context is restored when sleep times out. */
83
    context_t sleep_timeout_context;    /**< From here, the stored failover context is restored when sleep times out. */
Line 115... Line 115...
115
    ARCH_THREAD_DATA;           /**< Architecture-specific data. */
115
    ARCH_THREAD_DATA;           /**< Architecture-specific data. */
116
 
116
 
117
    __u8 *kstack;               /**< Thread's kernel stack. */
117
    __u8 *kstack;               /**< Thread's kernel stack. */
118
};
118
};
119
 
119
 
-
 
120
/** Structure passed to uinit kernel thread as argument. */
-
 
121
typedef struct uspace_arg {
-
 
122
    __address uspace_entry;
-
 
123
    __address uspace_stack;
-
 
124
} uspace_arg_t;
-
 
125
 
120
/** Thread list lock.
126
/** Thread list lock.
121
 *
127
 *
122
 * This lock protects all link_t structures chained in threads_head.
128
 * This lock protects all link_t structures chained in threads_head.
123
 * Must be acquired before T.lock for each T of type thread_t.
129
 * Must be acquired before T.lock for each T of type thread_t.
124
 *
130
 *
Line 137... Line 143...
137
 
143
 
138
extern void thread_register_call_me(void (* call_me)(void *), void *call_me_with);
144
extern void thread_register_call_me(void (* call_me)(void *), void *call_me_with);
139
extern void thread_print_list(void);
145
extern void thread_print_list(void);
140
extern void thread_destroy(thread_t *t);
146
extern void thread_destroy(thread_t *t);
141
 
147
 
142
 
-
 
143
/* Fpu context slab cache */
148
/* Fpu context slab cache */
144
extern slab_cache_t *fpu_context_slab;
149
extern slab_cache_t *fpu_context_slab;
145
 
150
 
-
 
151
/** Thread syscall prototypes. */
-
 
152
__native sys_thread_create(__address function, void *arg, void *stack, char *name);
-
 
153
__native sys_thread_exit(int status);
-
 
154
 
146
#endif
155
#endif