Skip to content

MDK-4203/Pulse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

readme

⚡ Pulse Process Controller

A high-performance, multi-threaded terminal utility for real-time system monitoring and process management on Linux.


📋 Abstract

Pulse is a dedicated, terminal-based utility developed to provide Linux users with a powerful, real-time interface for system monitoring and process management. Designed as a functional alternative to standard tools like top or htop, Pulse goes beyond simple observation by integrating interactive control features. It allows users to directly manage process priority, scheduling, and termination from a dynamic, continuously updated display.

✨ Key Features

  • Real-time Monitoring: Continuous updates of process metadata (PID, CPU%, Memory, State) directly from the /proc filesystem.
  • Process Control: Interactively kill processes, adjust nice values, and change scheduling policies (SCHED_FIFO, SCHED_RR) in real-time.
  • Multi-threaded Architecture: Separation of data collection, UI rendering, and command execution to ensure a responsive interface even under high load.
  • Zombie Management: Automatic handling of child processes using SIGCHLD signal handlers to prevent resource accumulation.
  • Terminal User Interface (TUI): A clean, ANSI-code based UI with color-coded process states (Running, Sleeping, Zombie, etc.).

🏗️ Architecture & Design

Pulse is built on a multi-threaded, producer-consumer model to ensure that data collection and rendering do not block user input or command execution.

Thread Model

Thread Function Role
Main Thread main() loop Manages non-blocking user input and queues process control commands.
Scanner Thread scanner_thread_func Data Producer: Periodically scans /proc and updates the shared process table.
UI Thread ui_thread_func Data Consumer: Acquires a read lock to render the TUI without blocking data collection.
Control Thread control_thread_func Command Consumer: Executes system calls (kill, setpriority) based on user input.

Synchronization

To maintain data integrity and responsiveness, Pulse employs standard POSIX synchronization primitives:

  • Read-Write Lock (RWLock): Protects the global process_table_t, allowing the UI thread (reader) to access data concurrently while blocking the Scanner thread (writer) only during updates.
  • Mutex & Command Queue: Ensures atomic queuing and dequeuing of user commands between the Main and Control threads.

🚀 Installation & Build

Prerequisites

  • Linux Environment
  • GCC Compiler
  • POSIX Threads Library (pthread)

⚙️ Technical Implementation Details

OS Integration

  • Process Information: Direct reading of /proc/<pid>/stat and /proc/<pid>/statm.
  • Scheduling: Utilizes setpriority for nice value adjustment and standard scheduler APIs for policy changes.
  • Signal Handling: Implements waitpid in the SIGCHLD handler to prevent zombie process accumulation.

Key Modules

  • Data Acquisition (procfs.c): Parses kernel data structures to extract CPU times and memory usage. Calculates CPU usage percentage based on delta changes between scans.
  • User Interface (ui.c): Manages termios for raw mode input and uses ANSI escape codes for cursor control and coloring.
  • Scheduler (scheduler.c): Wraps system calls to safely modify process states and attributes.

👤 Author

Daniyal Aftab Mirza

📚 Project: Operating Systems Semester Project

📜 Disclaimer

This project is developed for educational purposes to demonstrate core Operating System concepts such as concurrency control, process management, and low-level system programming.

About

A high-performance, multi-threaded terminal utility for real-time Linux system monitoring and process management, interfacing directly with /proc filesystem and implementing POSIX synchronization for responsive TUI.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors