Skip to content

Creating a New Process

Gehrig Wilcox edited this page Aug 3, 2018 · 1 revision

Creating a New Process

This explains what happens when the kernel creates a new process

  1. The function process_t createProcess(uint executableLocation) is called
  2. The kernel creates a new process_t
  3. Increment uint16_t nextPID
  4. If nextPID overflows, return
  5. Otherwise, set uint16_t PID to nextPID
  6. The kernel then runs through memory until it runs into the EOF characters, recording how large the file is
  7. Next, the kernel attempts to allocate the smallest block that will fit the executable by calling void* allocateBlock(uint8_t size)
  8. If the kernel cannot allocate a block, it will return a null pointer
  9. 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
  10. Set int* stackPointer to the processes stack
  11. Set pageTable_t* pageTable to a newly created pageTable_t
  12. Get the first process
  13. Get the first processes process_t* previousProcess
  14. Set that processes process_t* nextProcess to the new process
  15. Set the new processes previousProcess to the first processes previousProcess
  16. Set the first processes previousProcess to the new process
  17. And set the new processes nextProcess to the first process
Clone this wiki locally