Skip to content

SHaiderM16/news-agency-pubsub-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

News Agency Publishing and Subscribing System

Welcome to the News Agency Publishing and Subscribing System! This project implements an efficient publish-subscribe model, allowing news agencies to publish news articles and subscribers to receive updates based on their selected categories.

Project Background

This News Agency Publishing and Subscribing System was developed as part of an academic project to explore multithreading, interprocess communication (IPC), and synchronization mechanisms. The project simulates a real-world publisher-subscriber scenario where multiple news agencies publish articles, and subscribers receive updates dynamically.

The system is designed with multiprocessing, multithreading, and synchronization techniques such as message queues, shared memory, and semaphores, ensuring efficient and concurrent news delivery.

Features

  • Publisher-Subscriber Model: News agencies (publishers) generate news articles, while users (subscribers) receive updates in real-time.
  • Multi-Category Support: Subscribers can choose from various categories, such as Sports, Politics, and Entertainment.
  • Concurrency & Synchronization: Implements multithreading and IPC to handle simultaneous news updates without conflicts.
  • Efficient Communication: Uses shared memory to facilitate interprocess communication.
  • Dynamic Subscription: Subscribers can modify their preferences and receive only relevant news updates.

Installation

To compile and run the News Agency Publishing and Subscribing System, follow these steps:

Prerequisites

Ensure you have the following installed on your system:

  • GCC Compiler (for compiling C code)
  • POSIX Thread Library (for multithreading support)
  • IPC Mechanisms (such as message queues and shared memory)
  • Platform: Designed for Linux/Unix systems. Windows users can use MinGW or Windows Subsystem for Linux (WSL).

Setup

  1. Clone the repository:

    git clone https://github.com/SHaiderM16/news-agency-pubsub-system.git
  2. Navigate to the project directory:

    cd news-agency-pubsub-system
  3. Compile the binaries using the provided Makefile:

    make
  4. Run the components (in separate terminals):

    ./m        # Manager
    ./p -i     # Publisher (interactive mode)
    ./c -a     # Subscriber (subscribe to all categories)

Key Notes

  • The project consists of three main components:
    • Manager: Sets up shared memory and message queues.
    • Publisher Module: Publishes news articles based on publisher's input.
    • Subscriber Module: Receives and displays news updates based on selected categories.
  • Synchronization is handled using mutexes and atomic variables to ensure thread-safe operations.
  • Real-time updates and dynamic category subscription are supported.

Project Structure

  • project.h: Header file with shared constants and function declarations.
  • project.c: Shared utility functions used by all modules.
  • manager.c: Initializes shared resources and manages the system.
  • publisher.c: Handles publishing articles to selected categories.
  • subscriber.c: Handles user subscription and receives news.
  • Makefile: Compilation instructions for building all components.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

For any questions or feedback, please open an issue on the GitHub repository.

About

Real-time news publishing system implementing publish-subscribe pattern with C, demonstrating OS concepts like IPC, synchronization, and multithreading through shared memory and POSIX threads.

Topics

Resources

License

Stars

Watchers

Forks

Contributors