fork return value
This commit is contained in:
@@ -26,7 +26,7 @@ void switchToUsermode(void *stackpointer, void *kickoff,
|
||||
"pushq %[user_eflags] \n" \
|
||||
"pushq %[user_code] \n" \
|
||||
"pushq %[user_function] \n" \
|
||||
"mov %[user_parameter], %%rdi\n" \
|
||||
"mov %[user_parameter], %%rax\n" \
|
||||
"iretq \n" \
|
||||
: \
|
||||
: [user_data] "r"((uint64_t)user_ds),
|
||||
|
||||
@@ -296,10 +296,14 @@ int fork(Vault &vault, InterruptContext *user_context) {
|
||||
copy_stack(parent, child);
|
||||
|
||||
child->StackPointer.user = (void*)user_context->sp;
|
||||
vault.thread_list[child->id] = child;
|
||||
|
||||
//return parent pid to child
|
||||
prepareContext(child->StackPointer.isr, child->context, Thread::kickoff, reinterpret_cast<uintptr_t>(child), parent->id, 0);
|
||||
vault.scheduler.ready(child);
|
||||
|
||||
return 0;
|
||||
// return child pid to parent
|
||||
return child->id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,13 +16,12 @@ extern pagetable_t identity_table;
|
||||
void Thread::kickoff(uintptr_t param1, uintptr_t param2, uintptr_t param3) {
|
||||
Thread *thread = reinterpret_cast<Thread *>(param1);
|
||||
assert(thread != nullptr && "Kickoff got nullptr pointer to Thread");
|
||||
(void)param2; // will be used later
|
||||
(void)param3; // will be used later
|
||||
// The core must have entered level 1/2 to cause a thread to be scheduled.
|
||||
Guard::leave();
|
||||
|
||||
if(!thread->isKernel)
|
||||
Core::Ring::switchToUsermode(thread->StackPointer.user, thread->start, 0);
|
||||
Core::Ring::switchToUsermode(thread->StackPointer.user, thread->start, (void*)param2);
|
||||
else
|
||||
if(thread->start == nullptr)
|
||||
thread->action();
|
||||
|
||||
@@ -75,11 +75,11 @@ class Thread {
|
||||
* \param param3 Third parameter (will be used later)
|
||||
*
|
||||
*/
|
||||
static void kickoff(uintptr_t param1, uintptr_t param2, uintptr_t param3);
|
||||
|
||||
static void kickoffUsermode (Thread *object);
|
||||
void map_app(void* code_paddr, uint16_t code_page_num, void* stack_vaddr, uint16_t stack_page_num);
|
||||
public:
|
||||
static void kickoff(uintptr_t param1, uintptr_t param2, uintptr_t param3);
|
||||
struct{
|
||||
void* user;
|
||||
void* isr;
|
||||
|
||||
Reference in New Issue
Block a user