Creating a process/thread now always has parameters
This commit is contained in:
parent
ffa12e9625
commit
d4fa7974b7
@ -89,7 +89,7 @@ char load_proc(size_t datapos,char* initrd) {
|
||||
}
|
||||
copy_data(address_space,ptr,pheader.memsz,(void*)pheader.vaddr);
|
||||
}
|
||||
create_proc((void*)header.entry,address_space);
|
||||
create_proc((void*)header.entry,address_space,NULL,NULL);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -122,7 +122,7 @@ char load_proc(size_t datapos,char* initrd) {
|
||||
// }
|
||||
// copy_data(address_space,ptr,pheader.memsz,(void*)pheader.vaddr);
|
||||
// }
|
||||
// create_proc((void*)header.entry,address_space);
|
||||
// create_proc((void*)header.entry,address_space,NULL,NULL);
|
||||
// }
|
||||
// return 1;
|
||||
// }
|
||||
|
@ -202,7 +202,7 @@ void isr_handler(registers_t* r) {
|
||||
case 80:
|
||||
switch (r->eax) {
|
||||
case SYSCALL_CREATEPROC:
|
||||
tasking_create_task((void*)r->ebx,(void*)r->ecx,0,r->edx,(void*)r->esi,r->edx,(void*)r->edi,0);
|
||||
tasking_create_task((void*)r->ebx,(void*)r->ecx,0,(void*)r->edx,(void*)r->esi,0);
|
||||
break;
|
||||
case SYSCALL_YIELD:
|
||||
tasking_yield();
|
||||
@ -261,7 +261,7 @@ void isr_handler(registers_t* r) {
|
||||
memcpy((char*)r->ebx,initrd,initrd_sz);
|
||||
break;
|
||||
case SYSCALL_NEW_THREAD: {
|
||||
uint32_t tid=tasking_new_thread((void*)r->ebx,tasking_get_PID(),1,(void*)r->edx);
|
||||
uint32_t tid=tasking_new_thread((void*)r->ebx,tasking_get_PID(),(void*)r->edx);
|
||||
if ((uint32_t*)r->ecx!=NULL) {
|
||||
*((uint32_t*)r->ecx)=tid;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ void kmain(struct multiboot_boot_header_tag* hdr) {
|
||||
}
|
||||
copy_data(address_space,ptr,pheader.memsz,(void*)pheader.vaddr);
|
||||
}
|
||||
create_proc((void*)header.entry,address_space);
|
||||
create_proc((void*)header.entry,address_space,NULL,NULL);
|
||||
for (int i=0;i<4;i++) {
|
||||
yield();
|
||||
}
|
||||
|
@ -59,28 +59,12 @@ static void unmark_proc_scheduled(pid_t index) {
|
||||
proc_schedule_bmap[byte]=proc_schedule_bmap[byte]&(~(1<<bit));
|
||||
}
|
||||
|
||||
void tasking_create_task(void* eip,void* address_space,char kmode,char param1_exists,void* param1_arg,char param2_exists,void* param2_arg,char isThread) {
|
||||
void tasking_create_task(void* eip,void* address_space,char kmode,void* param1,void* param2,char isThread) {
|
||||
if (next_pid>MAX_PROCS && !isThread) {
|
||||
serial_printf("Failed to create a process, as 32k processes have been created already.\n");
|
||||
halt(); //Cannot ever create more than 32k processes, as I don't currently reuse PIDs.
|
||||
}
|
||||
void* param1;
|
||||
if (param1_exists) {
|
||||
param1=param1_arg;
|
||||
} else {
|
||||
param1=NULL;
|
||||
}
|
||||
void* param2;
|
||||
if (param2_exists) {
|
||||
if (isThread) {
|
||||
serial_printf("Param2 in Thread!\n");
|
||||
halt();
|
||||
}
|
||||
param2=param2_arg;
|
||||
} else {
|
||||
param2=NULL;
|
||||
}
|
||||
Process* proc=&processes[(pid_t)param2_arg];
|
||||
Process* proc=&processes[(pid_t)param2];
|
||||
Thread* thread=kmalloc(sizeof(Thread));
|
||||
if (isThread) {
|
||||
proc->num_threads++;
|
||||
@ -145,7 +129,7 @@ void tasking_init() {
|
||||
processes[i].num_threads=0;
|
||||
}
|
||||
|
||||
tasking_create_task(NULL,get_address_space(),1,0,0,0,0,0);
|
||||
tasking_create_task(NULL,get_address_space(),1,NULL,NULL,0);
|
||||
}
|
||||
|
||||
char tasking_is_privleged() {
|
||||
@ -160,8 +144,8 @@ int* tasking_get_errno_address() {
|
||||
return ¤t_thread->errno;
|
||||
}
|
||||
|
||||
pid_t tasking_new_thread(void* start,pid_t pid,char param_exists,void* param_arg) {
|
||||
tasking_create_task(start,NULL,0,param_exists,param_arg,0,(void*)pid,1);
|
||||
pid_t tasking_new_thread(void* start,pid_t pid,void* param) {
|
||||
tasking_create_task(start,NULL,0,param,(void*)pid,1);
|
||||
return processes[pid].first_thread->tid;
|
||||
}
|
||||
|
||||
|
@ -60,13 +60,11 @@ extern Thread* current_thread;
|
||||
* \param eip The start address of the task
|
||||
* \param address_space The address space of the task
|
||||
* \param kmode Whether the task is a kernel mode task
|
||||
* \param param1_exists Whether param1_arg is a valid value
|
||||
* \param param1_arg The thread's start function first parameter
|
||||
* \param param2_exists Whether param2_arg is a valid value
|
||||
* \param param2_arg The thread's start function second parameter/
|
||||
* \param isThread Whether we are creating a new process or a thread in a process. If we are creating a theead, param2_arg becomes the PID for the newly created thread, and param2_exists must be 0.
|
||||
* \param param1 The thread's start function first parameter
|
||||
* \param param2 The thread's start function second parameter
|
||||
* \param isThread Whether we are creating a new process or a thread in a process. If we are creating a theead, param2_arg becomes the PID for the newly created thread.
|
||||
*/
|
||||
void tasking_create_task(void* eip,void* address_space,char kmode,char param1_exists,void* param1_arg,char param2_exists,void* param2_arg,char isThread);
|
||||
void tasking_create_task(void* eip,void* address_space,char kmode,void* param1,void* param2,char isThread);
|
||||
/**
|
||||
* Initialize tasking
|
||||
*/
|
||||
@ -90,11 +88,10 @@ int* tasking_get_errno_address();
|
||||
* Create a new thread
|
||||
* \param start The start address of the task
|
||||
* \param pid The PID that gets the new thread
|
||||
* \param param_exists Whether param_arg is a valid value
|
||||
* \param param_arg The thread's start function parameter
|
||||
* \param param The thread's start function parameter
|
||||
* \return the TID of the thread
|
||||
*/
|
||||
pid_t tasking_new_thread(void* start,pid_t pid,char param_exists,void* param_arg);
|
||||
pid_t tasking_new_thread(void* start,pid_t pid,void* param);
|
||||
|
||||
/**
|
||||
* Terminate the current thread
|
||||
|
@ -12,18 +12,11 @@ void yield() {
|
||||
"::"b"(0));
|
||||
}
|
||||
|
||||
void create_proc(void* start,void* address_space) {
|
||||
void create_proc(void* start,void* address_space,void* param1,void* param2) {
|
||||
asm volatile(" \
|
||||
mov $" QU(SYSCALL_CREATEPROC) ", %%eax; \
|
||||
int $80; \
|
||||
"::"b"(start),"d"(0),"c"(address_space));
|
||||
}
|
||||
|
||||
void create_proc_param(void* start,void* address_space,void* param1,void* param2) {
|
||||
asm volatile(" \
|
||||
mov $" QU(SYSCALL_CREATEPROC) ", %%eax; \
|
||||
int $80; \
|
||||
"::"b"(start),"c"(address_space),"d"(1),"S"(param1),"D"(param2));
|
||||
"::"b"(start),"c"(address_space),"d"(param1),"S"(param2));
|
||||
}
|
||||
|
||||
__attribute__((noreturn)) void exit(int code) {
|
||||
|
@ -30,16 +30,10 @@ void yield();
|
||||
* Create a process
|
||||
* \param start The start function of the process
|
||||
* \param address_space The address space of the process
|
||||
*/
|
||||
void create_proc(void* start,void* address_space);
|
||||
/**
|
||||
* Create a process with 2 arguments
|
||||
* \param start The start function of the process
|
||||
* \param address_space The address space of the process
|
||||
* \param param1 The first parameter of the process
|
||||
* \param param2 The second parameter of the process
|
||||
*/
|
||||
void create_proc_param(void* start,void* address_space,void* param1,void* param2);
|
||||
void create_proc(void* start,void* address_space,void* param1,void* param2);
|
||||
/**
|
||||
* Block the current thread
|
||||
* \param state The state to block it with
|
||||
|
Loading…
Reference in New Issue
Block a user