source: bootcd/isolinux/syslinux-6.03/core/thread/kill_thread.c

Last change on this file was e16e8f2, checked in by Edwin Eefting <edwin@datux.nl>, 3 years ago

bootstuff

  • Property mode set to 100644
File size: 853 bytes
Line 
1#include "thread.h"
2#include <limits.h>
3
4extern void __exit_thread(void);
5typedef void (*func_ptr)(void);
6
7void kill_thread(struct thread *thread)
8{
9    irq_state_t irq;
10    struct thread_block *block;
11
12    if (thread == current())
13        __exit_thread();
14
15    irq = irq_save();
16
17    /*
18     * Muck with the stack so that the next time the thread is run then
19     * we end up going to __exit_thread.
20     */
21    thread->esp->eip = __exit_thread;
22    thread->prio = INT_MIN;
23
24    block = thread->blocked;
25    if (block) {
26        struct semaphore *sem = block->semaphore;
27        /* Remove us from the queue and increase the count */
28        block->list.next->prev = block->list.prev;
29        block->list.prev->next = block->list.next;
30        sem->count++;
31
32        thread->blocked = NULL;
33        block->timed_out = true; /* Fake an immediate timeout */
34    }
35
36    __schedule();
37
38    irq_restore(irq);
39}
40
41
42
Note: See TracBrowser for help on using the repository browser.