A high-performance, multi-threaded terminal utility for real-time system monitoring and process management on Linux.
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.
- Real-time Monitoring: Continuous updates of process metadata (PID, CPU%, Memory, State) directly from the
/procfilesystem. - Process Control: Interactively kill processes, adjust
nicevalues, 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
SIGCHLDsignal handlers to prevent resource accumulation. - Terminal User Interface (TUI): A clean, ANSI-code based UI with color-coded process states (Running, Sleeping, Zombie, etc.).
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 | 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. |
To maintain data integrity and responsiveness, Pulse employs standard POSIX synchronization primitives:
- Read-Write Lock (
RWLock): Protects the globalprocess_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.
- Linux Environment
- GCC Compiler
- POSIX Threads Library (
pthread)
- Process Information: Direct reading of
/proc/<pid>/statand/proc/<pid>/statm. - Scheduling: Utilizes
setpriorityfor nice value adjustment and standard scheduler APIs for policy changes. - Signal Handling: Implements
waitpidin theSIGCHLDhandler to prevent zombie process accumulation.
- 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): Managestermiosfor 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.
Daniyal Aftab Mirza
📚 Project: Operating Systems Semester Project
This project is developed for educational purposes to demonstrate core Operating System concepts such as concurrency control, process management, and low-level system programming.