CST 334 - Learning Journal Week 2

Topics Covered: 

1. The fork() System Call:  fork() is a system call used to create a new process - known as the child - which is a nearly identical copy of the parent process. What clicked for me was how the return values distinguish the two: the parent receives the child’s process ID, and the child receives zero. That simple distinction is what allows the same code to “split” into two executing entities. I also learned that every call to fork() doubles the number of running processes, which explains why two consecutive fork() calls result in four processes total.

2. The exec() System Call: while fork() creates a copy, exec() replaces the current process image with a new program. This was initially confusing - why would you create a process only to immediately overwrite it? For example, when a shell executes a command, it first uses fork() to create a child, then the child calls exec() to load the new program, leaving the shell intact in the parent process. 

3. Parent vs. Child Process Behavior:  One subtle but important point is that after a fork(), the parent and child have independent copies of variables. Even though global variables start with the same values, they no longer share memory after the fork. 

4. Process States and Transitions: The process state diagram - running, ready, and blocked - helped me visualize what the CPU scheduler is doing behind the scenes. A process waiting for input can only move to “ready” once the input arrives; the scheduler then decides when it can actually run. That extra step ensures fairness and consistency.

5. CPU Scheduling Algorithms: We covered several algorithms that determine the order in which processes are run. FIFO (or FCFS) is the simplest. Jobs are executed in the order they arrive, but it often leads to long waiting times for shorter processes. SJF and SRT improve this by prioritizing shorter tasks, reducing average response and turnaround times. I especially enjoyed working through examples that required calculating turnaround times under different algorithms. 

Least Understood Topics: 

1. Shortest Time Remaining(SRT): The preemption part was the most confusing. I understand that SRT is a preemptive version of SJF - meaning a process can be interrupted if a shorter one arrives, but keeping track of remaining times and arrival overlaps can get tricky. It is easy to make a timing mistake when doing it by hand especially if several processes arrive while one is already running.

2. Process Synchronization: I can see how the isolation between parent and child processes could make communication difficult. It makes me wonder how the system manages coordination without shared memory. 

"Aha" Moment: 

- Understanding how fork() and exec() work together. Every time a terminal is open and run a command, this pair of calls is being used under the hood. It also helped me understand why exec() doesn't return on success.

Questions from this week:

1. How do processes communicate or share data if they don't share memory after a fork()?

2. How does virtualization handle process scheduling when you have multiple operating systems sharing one physical CPU?

Connections: 

Similarities to programming: threads always seemed like 'lighter process" and now I can see that. A process has its own address space, while threads share one within the same process. 


Comments

Popular posts from this blog

CST 349 - Week 4 Learning Journal

CST349 Week 2 - Learning Journal

CST 349 - Week 5 Learning Journal