This repository contains various C programming projects demonstrating key Operating System concepts such as process control, threading, synchronization, and inter-process communication.
- Address Book Implementation
- Process Control with Fork, Execve, and Wait
- Matrix Multiplication Using Pthreads
- Producer-Consumer Problem
- Dining Philosophers Problem
- Inter-Process Communication Using Pipes
- Inter-Process Communication Using Shared Memory
- A C compiler (GCC recommended)
- POSIX compliant system (Linux or macOS)
pthreadlibrary for threading examples
Each program can be compiled using the following command:
gcc program_name.c -o program_name -lpthreadReplace program_name.c with the name of the C file you want to compile.
After compiling, run the program using:
./program_nameThis program allows users to create, view, insert, delete, and modify records in an address book.
- Create Address Book
- View Address Book
- Insert a Record
- Delete a Record
- Modify a Record
- Exit
- Compile the program:
gcc address_book.c -o address_book
- Run the program:
./address_book
This program demonstrates the use of fork, execve, and wait system calls. The parent process sorts an integer array and passes it to the child process, which performs a binary search.
- Compile the program:
gcc process_control.c -o process_control
- Run the program:
./process_control
This application demonstrates matrix multiplication using multithreading with the pthread library. Each thread computes a part of the product, and results are collected in the main thread.
- Compile the program:
gcc matrix_multiplication.c -o matrix_multiplication -lpthread
- Run the program:
./matrix_multiplication
This example uses counting semaphores and mutexes to demonstrate the producer-consumer problem. The producer generates data, and the consumer processes it.
- Compile the program:
gcc producer_consumer.c -o producer_consumer -lpthread
- Run the program:
./producer_consumer
This implementation shows the dining philosophers problem, demonstrating how to avoid deadlock and starvation using semaphores.
- Compile the program:
gcc dining_philosophers.c -o dining_philosophers -lpthread
- Run the program:
./dining_philosophers
This program implements full duplex communication between parent and child processes using pipes. The parent sends a file path, and the child returns the file contents.
- Compile the program:
gcc pipes_example.c -o pipes_example
- Run the program:
./pipes_example
This application demonstrates a client-server model using shared memory. The server writes a message to a shared memory segment, which the client reads and displays.
- Compile the server program:
gcc shared_memory_server.c -o shared_memory_server
- Compile the client program:
gcc shared_memory_client.c -o shared_memory_client
- Run the server in one terminal:
./shared_memory_server
- Run the client in another terminal:
./shared_memory_client
This project is licensed under the MIT License - see the LICENSE file for details.
Continue your learning journey and stay updated with more resources:
Happy coding! 😊