Skip to content

Latest commit

 

History

History
145 lines (101 loc) · 5.61 KB

File metadata and controls

145 lines (101 loc) · 5.61 KB

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!