Rev 1757 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1757 | Rev 1760 | ||
---|---|---|---|
Line 122... | Line 122... | ||
122 | 122 | ||
123 | /** Initialization and allocation for thread_t structure */ |
123 | /** Initialization and allocation for thread_t structure */ |
124 | static int thr_constructor(void *obj, int kmflags) |
124 | static int thr_constructor(void *obj, int kmflags) |
125 | { |
125 | { |
126 | thread_t *t = (thread_t *)obj; |
126 | thread_t *t = (thread_t *)obj; |
127 | pfn_t pfn; |
- | |
128 | int status; |
127 | int status; |
129 | 128 | ||
130 | spinlock_initialize(&t->lock, "thread_t_lock"); |
129 | spinlock_initialize(&t->lock, "thread_t_lock"); |
131 | link_initialize(&t->rq_link); |
130 | link_initialize(&t->rq_link); |
132 | link_initialize(&t->wq_link); |
131 | link_initialize(&t->wq_link); |
Line 140... | Line 139... | ||
140 | if (!t->saved_fpu_context) |
139 | if (!t->saved_fpu_context) |
141 | return -1; |
140 | return -1; |
142 | # endif |
141 | # endif |
143 | #endif |
142 | #endif |
144 | 143 | ||
145 | pfn = frame_alloc_rc(STACK_FRAMES, FRAME_KA | kmflags,&status); |
144 | t->kstack = frame_alloc_rc(STACK_FRAMES, FRAME_KA | kmflags,&status); |
146 | if (status) { |
145 | if (status) { |
147 | #ifdef ARCH_HAS_FPU |
146 | #ifdef ARCH_HAS_FPU |
148 | if (t->saved_fpu_context) |
147 | if (t->saved_fpu_context) |
149 | slab_free(fpu_context_slab,t->saved_fpu_context); |
148 | slab_free(fpu_context_slab,t->saved_fpu_context); |
150 | #endif |
149 | #endif |
151 | return -1; |
150 | return -1; |
152 | } |
151 | } |
153 | t->kstack = (__u8 *)PA2KA(PFN2ADDR(pfn)); |
- | |
154 | 152 | ||
155 | return 0; |
153 | return 0; |
156 | } |
154 | } |
157 | 155 | ||
158 | /** Destruction of thread_t object */ |
156 | /** Destruction of thread_t object */ |
159 | static int thr_destructor(void *obj) |
157 | static int thr_destructor(void *obj) |
160 | { |
158 | { |
161 | thread_t *t = (thread_t *)obj; |
159 | thread_t *t = (thread_t *)obj; |
162 | 160 | ||
163 | frame_free(ADDR2PFN(KA2PA(t->kstack))); |
161 | frame_free(KA2PA(t->kstack)); |
164 | #ifdef ARCH_HAS_FPU |
162 | #ifdef ARCH_HAS_FPU |
165 | if (t->saved_fpu_context) |
163 | if (t->saved_fpu_context) |
166 | slab_free(fpu_context_slab,t->saved_fpu_context); |
164 | slab_free(fpu_context_slab,t->saved_fpu_context); |
167 | #endif |
165 | #endif |
168 | return 1; /* One page freed */ |
166 | return 1; /* One page freed */ |