Main Page | Directories | File List | Globals

thread.c

Go to the documentation of this file.
00001 /*
00002  * kernel_sys/thread.c
00003  *
00004  * Copyright (c) 2003-2004 Lukasz Dembinski <dembol@nasa.com.pl>
00005  * All Rights Reserved
00006  * 
00007  * Date:        2004/04
00008  * Author:      Lukasz Dembinski
00009  * Info:        thread.c core file
00010  * Contact:     mailto: <dembol@nasa.com.pl>
00011  *
00012  */
00013 
00014 /*
00015  * TODO:
00016  * - switching to user mode 
00017  */
00018 
00019 #include <agnix/agnix.h>
00020 #include <asm/tss.h>
00021 #include <agnix/tasks.h>
00022 #include <agnix/list.h>
00023 #include <agnix/console.h>
00024 #include <agnix/spinlock.h>
00025 #include <agnix/panic.h>
00026 #include <agnix/errno.h>
00027 #include <agnix/unistd.h>
00028 #include <agnix/linkage.h>
00029 
00030 #define MOD_NAME        "THREAD: "
00031 
00032 int create_kernel_thread(const char *name, void (*thread_proc)(void *), void *data) 
00033 {
00034     __asm__ __volatile__ (
00035         "movl %%esp, %%esi\n\t"
00036         "int $0x80\n\t"
00037         "cmpl %%esp, %%esi\n\t"
00038         "je 1f\n\t"
00039 
00040         "pushl %%edi\n\t"
00041         "call *%2\n\t"
00042         "1:"
00043     :
00044     :"a"(__NR_fork), "b"(name), "r"(thread_proc), "D"((u32)data)
00045     );
00046 
00047     if (current_task->t_pid)
00048         kernel_panic("Kernel thread terminated...\n");
00049 
00050     return 0;
00051 }
00052 
00053 int create_user_thread(const char *name, void (*thread_proc)(void *data), void *data) 
00054 {
00055     fork();
00056     
00057     if (current_task->t_pid > 0) {
00058 //      task_set_user_mode(&(current_thread->tss_wrap->tss), 
00059         (*thread_proc)(data);
00060     } else 
00061     if (current_task->t_pid < 0) {
00062         kernel_panic(MOD_NAME "I can not create kernel thread\n");
00063     }
00064     
00065     return 0;
00066 }
00067 
00068 int threads_init(void)
00069 {
00070     return 0;
00071 }
Dokumentacje wygenerowano programem Doxygen 1.4.2 dla projektu Agnix