Rev 822 | Rev 860 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 822 | Rev 842 | ||
---|---|---|---|
Line 93... | Line 93... | ||
93 | /** Initialization and allocation for thread_t structure */ |
93 | /** Initialization and allocation for thread_t structure */ |
94 | static int thr_constructor(void *obj, int kmflags) |
94 | static int thr_constructor(void *obj, int kmflags) |
95 | { |
95 | { |
96 | thread_t *t = (thread_t *)obj; |
96 | thread_t *t = (thread_t *)obj; |
97 | pfn_t pfn; |
97 | pfn_t pfn; |
- | 98 | int status; |
|
98 | 99 | ||
99 | spinlock_initialize(&t->lock, "thread_t_lock"); |
100 | spinlock_initialize(&t->lock, "thread_t_lock"); |
100 | link_initialize(&t->rq_link); |
101 | link_initialize(&t->rq_link); |
101 | link_initialize(&t->wq_link); |
102 | link_initialize(&t->wq_link); |
102 | link_initialize(&t->th_link); |
103 | link_initialize(&t->th_link); |
103 | link_initialize(&t->threads_link); |
104 | link_initialize(&t->threads_link); |
104 | 105 | ||
105 | pfn = frame_alloc(ONE_FRAME, FRAME_KA | kmflags); |
106 | pfn = frame_alloc_rc(ONE_FRAME, FRAME_KA | kmflags,&status); |
106 | t->kstack = (__u8 *)PA2KA(PFN2ADDR(pfn)); |
- | |
107 | if (!t->kstack) |
107 | if (status) |
108 | return -1; |
108 | return -1; |
- | 109 | t->kstack = (__u8 *)PA2KA(PFN2ADDR(pfn)); |
|
109 | 110 | ||
110 | return 0; |
111 | return 0; |
111 | } |
112 | } |
112 | 113 | ||
113 | /** Destruction of thread_t object */ |
114 | /** Destruction of thread_t object */ |
Line 227... | Line 228... | ||
227 | { |
228 | { |
228 | thread_t *t; |
229 | thread_t *t; |
229 | ipl_t ipl; |
230 | ipl_t ipl; |
230 | 231 | ||
231 | t = (thread_t *) slab_alloc(thread_slab, 0); |
232 | t = (thread_t *) slab_alloc(thread_slab, 0); |
- | 233 | if (!t) |
|
- | 234 | return NULL; |
|
232 | 235 | ||
233 | /* Not needed, but good for debugging */ |
236 | /* Not needed, but good for debugging */ |
234 | memsetb((__address)t->kstack, THREAD_STACK_SIZE, 0); |
237 | memsetb((__address)t->kstack, THREAD_STACK_SIZE, 0); |
235 | 238 | ||
236 | ipl = interrupts_disable(); |
239 | ipl = interrupts_disable(); |