- Objective: Demonstrate Inter-Process Communication (IPC) using bidirectional pipelines.
-
Mechanism: * The parent process (
$P_1$ ) acts as the orchestrator. It reads an integer$N$ from standard input and generates two distinct text files containing$N$ random numbers. - The numbers are upper-bounded by a threshold derived dynamically via a customized ID offset system macro (
#define TC_LAST_3DIG 111) to enforce absolute standard compliance. - Two child processes (
$P_2$ and$P_3$ ) are spawned usingfork(). Communication routes are established using discrete UNIXpipe()file descriptors. -
$P_2$ parsesFile1to count Prime Numbers, while$P_3$ parsesFile2to count Abundant Numbers. Results are piped back to the parent to declare the mathematical winner.
- Objective: Manage CPU bound multi-threaded synchronization tasks under tight hardware constraint simulation.
- Mechanism:
- Uses the POSIX threads (
pthread) library alongside standard UNIX counting semaphores (sem_t). - Accepts a directory pathway containing target data files and a strict constraint integer mapping out the maximum concurrently active worker threads allowed inside the processing zone.
- Threads parallelly read the datasets to count Deficient Numbers while leveraging semaphores to ensure the worker boundary constraint is never breached.
- Real, user, and kernel system execution times are calculated via the UNIX
timeutility across incremental thread pool scalability configurations to observe core scheduling overheads.
- Objective: Implement a customized variant of the classic Reader-Writer synchronization problem with token/password security layer controls.
- Mechanism:
- Uses a robust layer of POSIX Mutexes (
pthread_mutex_t) and binary semaphores to build a race-condition-free data structure. - A master password verification routing table is auto-generated upon start. Only real reader/writer threads configured with authentic structural memory vectors can interact with the global shared database system (
BUFFER). - Equal streams of rogue dummy processes are concurrently instantiated with faulty structural passwords to rigorously test cross-thread validation and rejection boundaries.
- Execution flows are formatted as fully traceable transaction logs mapping operational roles, validation flags, and synchronized runtime snapshots.
A native GNU/Linux toolchain (gcc) is highly recommended for building these systems.
# Compile Homework 1 (Multiprocess & Pipes)
gcc -g hw1-382/main.c -o hw1-382/main
# Compile Homework 2 (Multi-threading & Semaphores)
gcc -g hw2-382/hw2_main.c -o hw2-382/hw2_main -lpthread
# Compile Homework 3 (Reader-Writer with Passwords)
gcc -g hw3-382/hw3_main.c -o hw3-382/hw3_main -lpthread
# Execution for Homework 1
./hw1-382/main
# Execution for Homework 2 (Process 'myDir' using maximum 4 parallel threads)
chmod +x hw2-382/new.sh
./hw2-382/new.sh # Generates sample data directory 'myDir'
time ./hw2-382/hw2_main myDir 4
# Execution for Homework 3
./hw3-382/hw3_main