Skip to content

C programs demonstrating process creation and synchronization in Linux using fork() and wait(), including process hierarchies, zombie/orphan handling, and dynamic child process creation (Operating Systems II, UNIWA).

Notifications You must be signed in to change notification settings

Operating-Systems-2-aka-Uniwa/Fork

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

UNIWA

UNIVERSITY OF WEST ATTICA
SCHOOL OF ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING AND INFORMATICS


Operating Systems II

Process Management with Fork and Wait in C

Vasileios Evangelos Athanasiou
Student ID: 19390005

GitHub · LinkedIn


Supervision

Supervisor: Vasileios Mamalis, Professor

UNIWA Profile

Co-supervisor: Nikolaos Psarras, Applications Lecturer

UNIWA Profile · LinkedIn

Athens, April 2022


Process Management with Fork and Wait in C

This repository contains an assignment for Operating Systems II, focusing on process creation, management, and synchronization in C using fork() and wait() system calls.


Table of Contents

Section Folder/File Description
1 assign/ Assignment material for the Fork processes workshop
1.1 assign/ASK-1-OS-II-LAB-2021-22.pdf Assignment description in English
1.2 assign/ΕΡΓ-1-ΛΣ-ΙΙ-ΕΡΓ-2021-22.pdf Assignment description in Greek
2 docs/ Documentation covering process creation using fork
2.1 docs/Fork-Processes.txt English documentation for fork processes
2.2 docs/Fork-Διεργασίες.txt Greek documentation for fork processes
3 src/ Source code demonstrating fork usage
3.1 src/exer1a.c Exercise source code using fork
3.2 src/fork.c Basic fork process example
4 README.md Repository overview and usage instructions

Project Overview

The assignment involves developing a C program that:

  • Creates a total of seven processes following a specific hierarchy.
  • Implements process synchronization to avoid zombie processes.
  • Demonstrates inter-process communication.
  • Explores scenarios with orphan and zombie processes.
  • Allows process P2 to spawn N child processes dynamically based on user input.

Key Learning Outcomes

  • Understand and apply fork() and wait() system calls.
  • Create and manage process hierarchies.
  • Synchronize parent and child processes effectively.
  • Handle inter-process communication and message passing.
  • Investigate orphan and zombie processes and prevention techniques.

Process Tree Structure

The program creates processes with the following hierarchy:

			  (P0)
			  /|\
			 / | \
            /  |  \
	       /   |   \ 
          /    |    \
        (P1)  (P3) (P4)
        /      |
       /       |
      /        | 
     /         |
   (P2)       (P5)

Requirements

  • Operating System: Linux or Unix-like environment
  • Compiler: GCC (GNU Compiler Collection)
  • System Calls: fork(), wait(), execv(), and others as needed

Installation & Usage

1. Clone the Repository

git clone https://github.com/Operating-Systems-2-aka-Uniwa/Fork.git
cd Fork

2. Compile Source Code

gcc -o exer1a exer1a.c
gcc -o fork fork.c

3. Run Executables

./exer1a
./fork

About

C programs demonstrating process creation and synchronization in Linux using fork() and wait(), including process hierarchies, zombie/orphan handling, and dynamic child process creation (Operating Systems II, UNIWA).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages