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.
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.
- 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.
To compile and run the News Agency Publishing and Subscribing System, follow these steps:
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).
-
Clone the repository:
git clone https://github.com/SHaiderM16/news-agency-pubsub-system.git
-
Navigate to the project directory:
cd news-agency-pubsub-system -
Compile the binaries using the provided Makefile:
make
-
Run the components (in separate terminals):
./m # Manager ./p -i # Publisher (interactive mode) ./c -a # Subscriber (subscribe to all categories)
- 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.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.
This project is licensed under the MIT License - see the LICENSE file for details.
For any questions or feedback, please open an issue on the GitHub repository.