/* * Start a user-mode thread (i.e., a process), using given user context. * Returns pointer to the new thread if successful, null otherwise. */ struct Kernel_Thread* Start_User_Thread(struct User_Context* userContext, bool detached) { /* * Hints: * - Use Create_Thread() to create a new "raw" thread object * - Call Setup_User_Thread() to get the thread ready to * execute in user mode * - Call Make_Runnable_Atomic() to schedule the process * for execution */ struct Kernel_Thread* kthread; kthread = Create_Thread(PRIORITY_USER, detached); if (kthread != 0) { /* * Create the initial context for the thread to make * it schedulable. */ Setup_User_Thread(kthread, userContext); /* Atomically put the thread on the run queue. */ Make_Runnable_Atomic(kthread); } return kthread; }
/* * Start a user-mode thread (i.e., a process), using given user context. * Returns pointer to the new thread if successful, null otherwise. */ struct Kernel_Thread* Start_User_Thread(struct User_Context* userContext, bool detached) { //lacki /* * Hints: * - Use Create_Thread() to create a new "raw" thread object * - Call Setup_User_Thread() to get the thread ready to * execute in user mode * - Call Make_Runnable_Atomic() to schedule the process * for execution */ //TODO("Start user thread"); struct Kernel_Thread *pKernel_Thread = Create_Thread(PRIORITY_NORMAL, detached); if (pKernel_Thread != 0) { Setup_User_Thread(pKernel_Thread, userContext); Make_Runnable_Atomic(pKernel_Thread); return pKernel_Thread; } else { DEBUG("ERROR: Start_User_Thread - not able to create thread"); return 0; } }