This project's primary objective is to architect and bring to life an enhanced Task Controller that prioritizes task synchronization. This solution lets individuals establish, oversee, and synchronize tasks in an environment riddled with multiple threads. Moreover, it boasts a CLI (Command-Line Interface) for task creation, oversight, and synchronization. Underneath, the system leans on system calls to direct both tasks and threads.
This Process Manager project includes the following functionalities:
- Task Establishment
- Overseeing Tasks (Overview, Halting, and Supervision)
- Thread Features (Spawning Threads and Overview)
- Task-to-Task Communication (T2T)
- Task Syncing (Supply-Demand Problem)
- Command-Line Operations (CLO)
- Documentation and Analysis
-
Install Python 3.11.6 from the official Python website: Python Downloads.
-
Clone the repository and cd into it:
git clone https://github.com/jrobin11/Advanced-Process-Manager-with-Process-Synchronization.git cd Advanced-Process-Manager-with-Process-Synchronization
-
Install psutil
pip install psutil
-
Create a Virtual Environment (recommended):
- On macOS and Linux:
- Open the Terminal.
- Navigate to your project directory using the
cd
command. - Activate the virtual environment:
source venv/bin/activate
- On macOS and Linux:
Options:
1. Create a new process
2. Initiate a new thread
3. View all processes
4. View threads within a process
5. Terminate a process
6. Terminate a thread
7. IPC: Send message to child processes
8. IPC: Fetch message from child process
9. IPC: Queue - Send data
10. IPC: Queue - Receive data
11. Produce an item
12. Signal a child process
13. Non-blocking read from a pipe
14. Wake up a sleeping thread
15. Exit the program
"Enter you choice (1-15)"
- Run the Process Manager
- Select the option to create a new process
- Enter the process name
- A new process is created
- User Interaction: A prompt asks the user to input a name for the process.
- Backend Operation: The create_process method initializes a new process. Depending on the environment, this could be done using the fork system call in UNIX-like systems or using process APIs in other systems.
This test will check to see if the process manager is able to initate a new thread
- Run the Process Manager
- Enter the new thread name
- A thread with the specified name is created
- User Interaction: User is prompted to provide a name for the thread.
- Backend Operation: create_thread is called which, depending on the environment, will likely use threading libraries to initialize and start a thread within the current process context.
- Run the Process Manager.
- Select option 3 to view all process
- Then select option 4 to view all threads within a processer
- should show all process and thread within a process
- User Interaction: Simply selecting this option.
- Backend Operation: list_processes method fetches a list of all running processes. This could be obtained using system commands or APIs that provide a list of processes.
- User Interaction: User selects the process for which they want to see threads.
- Backend Operation: The list_threads method gets a list of all active threads within the chosen process. Threading libraries or system-specific calls would be used for this.
Will check to see if it can terminate a thread and process
- View all thread and process
- Select 5 to terminate process
- Select 6 to terminate thread
- Enter the PID of the process
- The specified thread is terminated
- The specified process is terminated
- User Interaction: User provides the Process ID (PID) of the process they want to terminate.
- Backend Operation: terminate_process is called which sends a termination signal to the specified process. Methods like kill can be used in UNIX-like systems.
- User Interaction: User specifies the thread name they want to stop.
- Backend Operation: terminate_thread method stops the particular thread using appropriate threading libraries or system calls.
Will check to see if IPC sends message to child process
- Select 7 to send message
- Select 8 to check if message sent
- The message will appear
User Interaction: User chooses among sending/receiving messages or data.
- Backend Operations:
- send_message and receive_message are for message-based communication between processes. This might be implemented using message queues.
- send_data and receive_data methods are for sending and receiving data, perhaps through pipes or shared memory.
Will check if IPC queue sends data and receives it
- Select 9 to send data
- Select 10 to receive the data that was sent
- The data was sent
- The data displayed
This test validates the Process Manager's ability to send messages between processes using IPC. It uses named pipes (FIFOs) for inter-process communication and non-blocking reads to receive messages.
will check to see if a item can be produced
- Select 11
- Pick option 1 to produce
- It will produce an item
- User Interaction: Simply selecting this option.
- Backend Operation: An item (data) is produced and stored in a buffer. This simulates the producer side of the producer-consumer problem.
Will check to see if a child process can be signaled
- Select 12
- Enter the PID of the child process
- It should send a signal to the child process
- User Interaction: User specifies which child process to signal.
- Backend Operation: A signal (like SIGUSR1) is sent to the specified child process. This might be used to inform or interrupt the child process.
Will check Non-blocking readings from a pipe
- Select 13
- It should return the readings from the pipe
- User Interaction: Simply selecting this option.
- Backend Operation: An attempt is made to read a message from a pipe. If the pipe is empty, the function returns immediately without blocking.
- Will wake up a thread
- Select 14
- Enter the name of the thread that you want to wake up
- It should wake up the thread
- User Interaction: This option is not yet implemented.
- Backend Operation: In the future, this would likely involve sending a signal or using some threading library call to wake up a specified thread that's currently in a sleep or wait state.
The Advanced Process Manager leverages detailed documentation mechanisms to record pertinent information regarding processes, threads, inter-process interactions, and synchronization incidents. This documented data is stored in processes.log
.
-
**Initiation of Process and Threads: On the creation of any process or thread, specifics like process ID (PID), thread ID (TID), name, and current status are diligently noted in the log.
-
**Thread Conclusion: On the event of a thread's cessation, the log captures the activity, taking note of the ceased thread's name.
-
**Inter-Process Interactions (IPC): Every IPC message is logged with details of the sender process, receiver process, and the content of the message. This gives a thorough overview of IPC undertakings within the Process Manager.
-
**Synchronization Process (Producer-Consumer): Instances in the producer-consumer scenario, be it the generation or use of items, are chronicled to show the synchronization dynamics between producing and consuming threads.
-
**Cataloging Processes and Threads: Logs capture details of processes and threads, irrespective of whether they are derived from the script or are from the system-wide list.
-
**Log Reset: A "Clear log file" function is present, facilitating a fresh start for subsequent log sessions.
The log file, processes.log
, stands as an instrumental resource in scrutinizing the behaviors of processes and threads, rectifying anomalies, and grasping the synchronization facets within the Process Manager. It's a gateway for users to revisit previous operations, dissect discrepancies, and chronologically follow events across individual and multi-threaded modules.
The processes.log
file is created in the root directory of the Process Manager project. Users can access this file to view and analyze the logged information.
processes.log
is anchored in the primary directory of the Process Manager initiative. Users can delve into this log for insights.
Advanced-Process-Manager/
├── processes.log
├── ...
- The Advanced Process Manager exemplifies a thorough and intricate platform for overseeing processes and threads within multi-threaded configurations. This section delves into the core achievements of the project, spanning its functionalities, structural design, and the wider reach of its potential.
- The platform adeptly facilitates the inception of fresh processes, granting each its unique interactional menu. Such a granular approach to process initiation augments the system's capacity to handle diverse operations or services. A suite of controls, from listing to terminating processes, accentuates governance over these modules.
- Embedding threads within processes amplifies the functional spectrum of the project. This integration exemplifies the adeptness to manage applications running multiple threads, potentially seeding more intricate computational tasks. The finesse in initiating and concluding threads elucidates the Process Manager's authoritative command over them.
- The inclusion of IPC, sanctioning communication amongst processes, stands out as an invaluable asset. This champions cohesive operations and data sharing across processes. Especially in expansive and networked systems, IPC's relevance escalates, and this utility underscores its practicality.
- A standout element within the project is the portrayal of process synchronization through the Producer-Consumer paradigm. By emulating real-world synchronization hurdles, the prowess of the Process Manager in directing intricate thread interplays comes to the fore. Semaphore-oriented synchronization guarantees singular thread access to communal resources, an elemental tenet in concurrent computing.
- Integrating a meticulous documentation system, where all relevant actions are penned in processes.log, boosts the project's traceability and clarity. This document offers a historical overview, aiding in troubleshooting, efficiency analytics, and deriving systemic insights. The "Log Reset" function equips users to commence fresh logging sessions, upholding log purity.
Beyond being a conceptual showcase, the Advanced Process Manager manifests as a pragmatic instrument. Its versatility spans:
- System Governance: Offering a panoramic view of all active processes, it aids administrators in system supervision.
- Concurrent Computations: With its affinity for multi-threaded applications and IPC, it's pivotal in concurrent computing where tasks are parallelized for enhanced efficiency.
- Networked Architectures: In systems spread across machines, IPC's role is indispensable.
- Educative Resource: It can double up as an instructive asset, elucidating process governance and synchronization tenets.
Despite the Advanced Process Manager's formidable suite of tools, there's an expansive horizon for augmentation:
- Augmented IPC: Enriching IPC with evolved communication paradigms such as shared memory or messaging queues.
- User Experience: Sculpting a graphical user interface (GUI) for an intuitive user journey.
- Resource Surveillance: Integrating monitors for resources like CPU or memory will be invaluable for administrative oversight.
The Advanced Process Manager stands as a robust platform, proficient in process governance, thread management, IPC, and synchronized operations. Beyond its functionality, it embodies the essence of process governance and synchronization philosophies. The rigorous documentation ensures a transparent and accountable system experience. The foundation laid by this initiative primes it for further evolutionary strides in process governance and concurrent computational utilities, promising to cater to administrators, coders, and educators alike.