-
Couldn't load subscription status.
- Fork 0
Creating a New Process
Gehrig Wilcox edited this page Aug 3, 2018
·
1 revision
This explains what happens when the kernel creates a new process
- The function
process_t createProcess(uint executableLocation)is called - The kernel creates a new
process_t - Increment
uint16_t nextPID - If
nextPIDoverflows, return - Otherwise, set
uint16_t PIDtonextPID - The kernel then runs through memory until it runs into the EOF characters, recording how large the file is
- Next, the kernel attempts to allocate the smallest block that will fit the executable by calling
void* allocateBlock(uint8_t size) - If the kernel cannot allocate a block, it will return a null pointer
- If the kernel can allocate a block, it will reserve the memory block in the memory table and return a pointer to the memory block
- Set
int* stackPointerto the processes stack - Set
pageTable_t* pageTableto a newly createdpageTable_t - Get the first process
- Get the first processes
process_t* previousProcess - Set that processes
process_t* nextProcessto the new process - Set the new processes
previousProcessto the first processespreviousProcess - Set the first processes
previousProcessto the new process - And set the new processes
nextProcessto the first process