Animated Examples

Listen to me!

This is a simple forking program that simulates an argument between a parent and child. You will be learning how to trace fork() calls within for loops and understanding the different return values of fork() based on whether fork() is being called in a parent or child process.

The Hardworking Child

This is a simple forking program that takes user input and only executes certain lines of code if the process is a child process.

Fork()==Fork()

This is a forking problem that truly requires you to draw out a diagram to trace the output. You will encounter fork() statements within the condition of an if-statement and learn about the possible return values of a fork() call depending on which process calls it.

A Simple Wait

This is a simple forking program that introduces you to the waitpid() system call in C. The animated diagram is especially useful for this program because it will help you visualize the parent process waiting for the child process to terminate.

Starfork

This is an interesting forking problem that will require a diagram to trace the output. You will encounter additional function calls, fork() calls within a for-loop, and waitpid() calls.

Sleepy Program

This is a complicated forking() program that will introduce you to the concept of sleep() calls. Watching the animated diagram for this example is crucial for understanding how each process executes simultaneously.