CST 334 Week 2 Journal Entry

 Processes

This week in CST 334, we learned about processes. A process is a running program. It consists of an address space containing instruction and data and registers containing a program counter and stack pointer. Before a process starts running, it is considered a program. The code and data from the program are loaded into memory as well as the address space. Memory is then allocated on the run-time stack to hold local variables, function parameters, and return addresses. Next, memory is allocated to the program's heap. After some other initialization tasks, the program is ready to be executed, turning the program into a process.

Once started, a process can be in three states: Ready, Running, or Blocked. When a process is ready, it has not been executed on the operating system, but the necessary steps to perform the process have been completed. When a process is running, the processor executes the instruction from the process. When a process is blocked, it is not ready to run until some sort of action is taken (I/O request). When blocked, the operating system can allow the CPU to start running another process. This is called context switching. During a context switch, the operating system saves some registers, PC, and kernel stack pointers from the current process. It then restores registers from the upcoming process and switches to the kernel stack for the new process. The operation system continues to switch between processes this way until all processes have been run to their entirety or have been terminated. 


Comments

Popular posts from this blog

CST 300 - Week 8

CST 300 - Week 5

CST 300 - Week 4