Skip to content

devbyhimans/Operating_System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

KernelTalk: System-Level Chat Platform using OS System Calls

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

 
 
 

Contributors