Rev 2440 | Rev 2451 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2440 | Rev 2446 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
2 | * Copyright (c) 2001-2004 Jakub Jermar |
2 | * Copyright (c) 2001-2007 Jakub Jermar |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
Line 38... | Line 38... | ||
38 | #include <synch/waitq.h> |
38 | #include <synch/waitq.h> |
39 | #include <proc/task.h> |
39 | #include <proc/task.h> |
40 | #include <time/timeout.h> |
40 | #include <time/timeout.h> |
41 | #include <cpu.h> |
41 | #include <cpu.h> |
42 | #include <synch/rwlock.h> |
42 | #include <synch/rwlock.h> |
- | 43 | #include <synch/spinlock.h> |
|
43 | #include <adt/btree.h> |
44 | #include <adt/btree.h> |
44 | #include <mm/slab.h> |
45 | #include <mm/slab.h> |
45 | #include <arch/cpu.h> |
46 | #include <arch/cpu.h> |
46 | #include <mm/tlb.h> |
47 | #include <mm/tlb.h> |
47 | #include <proc/uarg.h> |
48 | #include <proc/uarg.h> |
Line 78... | Line 79... | ||
78 | Ready, |
79 | Ready, |
79 | /** Threads are in this state before they are first readied. */ |
80 | /** Threads are in this state before they are first readied. */ |
80 | Entering, |
81 | Entering, |
81 | /** After a thread calls thread_exit(), it is put into Exiting state. */ |
82 | /** After a thread calls thread_exit(), it is put into Exiting state. */ |
82 | Exiting, |
83 | Exiting, |
83 | /** Threads that were not detached but exited are in the Undead state. */ |
84 | /** Threads that were not detached but exited are in the JoinMe state. */ |
84 | Undead |
85 | JoinMe |
85 | } state_t; |
86 | } state_t; |
86 | 87 | ||
87 | /** Join types. */ |
- | |
88 | typedef enum { |
- | |
89 | None, |
- | |
90 | TaskClnp, /**< The thread will be joined by ktaskclnp thread. */ |
- | |
91 | TaskGC /**< The thread will be joined by ktaskgc thread. */ |
- | |
92 | } thread_join_type_t; |
- | |
93 | - | ||
94 | /** Thread structure. There is one per thread. */ |
88 | /** Thread structure. There is one per thread. */ |
95 | typedef struct thread { |
89 | typedef struct thread { |
96 | link_t rq_link; /**< Run queue link. */ |
90 | link_t rq_link; /**< Run queue link. */ |
97 | link_t wq_link; /**< Wait queue link. */ |
91 | link_t wq_link; /**< Wait queue link. */ |
98 | link_t th_link; /**< Links to threads within containing task. */ |
92 | link_t th_link; /**< Links to threads within containing task. */ |
Line 150... | Line 144... | ||
150 | * If true, the thread will not go to sleep at all and will call |
144 | * If true, the thread will not go to sleep at all and will call |
151 | * thread_exit() before returning to userspace. |
145 | * thread_exit() before returning to userspace. |
152 | */ |
146 | */ |
153 | bool interrupted; |
147 | bool interrupted; |
154 | 148 | ||
155 | /** Who joinins the thread. */ |
- | |
156 | thread_join_type_t join_type; |
- | |
157 | /** If true, thread_join_timeout() cannot be used on this thread. */ |
149 | /** If true, thread_join_timeout() cannot be used on this thread. */ |
158 | bool detached; |
150 | bool detached; |
159 | /** Waitq for thread_join_timeout(). */ |
151 | /** Waitq for thread_join_timeout(). */ |
160 | waitq_t join_wq; |
152 | waitq_t join_wq; |
- | 153 | /** Link used in the joiner_head list. */ |
|
- | 154 | link_t joiner_link; |
|
161 | 155 | ||
162 | fpu_context_t *saved_fpu_context; |
156 | fpu_context_t *saved_fpu_context; |
163 | int fpu_context_exists; |
157 | int fpu_context_exists; |
164 | 158 | ||
165 | /* |
159 | /* |