Skip to content

πŸ’» Hands-on C/C++ implementations of core Operating System concepts: system calls, IPC, threads, signals & synchronization with practical examples.

Notifications You must be signed in to change notification settings

devbyhimans/Operating_System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Operating System Concepts: Implementations and Examples

Welcome to the Operating Systems repository! This project is a collection of C programs that explore and implement fundamental concepts of operating systems, focusing on system calls, Inter-Process Communication (IPC) mechanisms, threads, signals, and classic synchronization problems.

πŸ“– Table of Contents

🌟 About The Project

This repository serves as a practical guide and hands-on implementation hub for key OS concepts. The goal is to provide clear, well-commented code that demonstrates how these low-level functionalities work. Whether you're a student learning about operating systems or a developer looking to refresh your knowledge, you'll find valuable examples here.

πŸš€ Core Concepts Covered

This repository contains implementations for the following topics:

πŸ“ž Basic System Calls

A collection of programs demonstrating the use of fundamental system calls for process management found in the basics directory.

  • fork(): Creating child processes.
  • wait(): Synchronizing parent and child processes.
  • sleep(): Suspending process execution.
  • getpid() & getppid(): Retrieving process and parent process IDs.

⚑ Threads & Signals

  • Threads: Implementations exploring multi-threading concepts.
  • Signals: Programs demonstrating how to handle signals for asynchronous event handling. This includes:
    • Setting up custom signal handlers using signal() and sigaction().
    • Sending signals to processes using the kill() system call.
    • Using signals for inter-process communication, such as in the sharedmemory_signal example.

πŸ”„ Inter-Process Communication (IPC)

Implementations of various IPC mechanisms to allow processes to communicate and synchronize their actions.

  • Anonymous Pipes: Unidirectional communication between related processes.
  • Named Pipes (FIFO): Communication between unrelated processes (TwoWayCommfifo).
  • Shared Memory: Allowing multiple processes to access the same memory segment.
  • Polling: Efficiently handling I/O from multiple sources.

πŸ”’ Synchronization Problems

Solutions to classic concurrency and synchronization problems, demonstrating how to avoid race conditions and deadlocks.

  • Producer-Consumer Problem
  • Reader-Writer Problem
  • Dining Philosophers Problem

πŸ’» Applications

Practical applications built using the concepts above to showcase their real-world utility.

  • One-to-One Chat System
  • Shared Chat System (Group Chat)
  • News Room Synchronization

πŸ“‚ Repository Structure

The code is organized into directories .

Operating_system
β”œβ”€β”€ Anonymouspipes/
β”œβ”€β”€ basics/
β”œβ”€β”€ pipes/
β”œβ”€β”€ poll/
β”œβ”€β”€ sharedmemory/
β”‚ β”œβ”€β”€ multi_message_Communication/
β”‚ └── ...
β”œβ”€β”€ signals/
β”‚ β”œβ”€β”€ sharedmemory_signal/
β”‚ β”œβ”€β”€ sigaction/
| | └── sharedmemory(using signal and handler function)/
β”‚ └── ...
β”œβ”€β”€ Threads/
β”œβ”€β”€ TwoWayCommfifo/
└── Process_Synchronization/
β”œβ”€β”€ Basic/
β”œβ”€β”€ Dinning_Philospher/
β”œβ”€β”€ Producer_consumer/
└── Reader_Writer/

πŸ› οΈ Getting Started

Follow these instructions to get the code up and running on your local machine.

Prerequisites

You will need a Cpp compiler (like g++) and a Unix-like operating system (Linux, macOS) to run these examples.

Compilation and Execution

  1. Clone the repository:
    git clone [https://github.com/your-username/your-repo-name.git\](https://github.com/your-username/your-repo-name.git)
    cd your-repo-name

  2. Navigate to a specific implementation's directory:
    cd pipes/

  3. Compile the C file using gcc:

    • For basic programs:
      g++ source_file.cpp -o output_file

    • When using threads (pthreads), you must link the pthread library:
      g++ -lpthread source_file.cpp -o output_file

    • When using the math library, link it with -lm:
      g++ -o output_file source_file.c -lm

  4. Run the compiled executable:
    ./output_file

    Note: Some programs, especially the chat applications, may require running multiple executables (e.g., a server and a client) in separate terminal windows.

πŸ™Œ Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

Distributed under the MIT License. See LICENSE for more information.

Happy Coding!

About

πŸ’» Hands-on C/C++ implementations of core Operating System concepts: system calls, IPC, threads, signals & synchronization with practical examples.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published