0% found this document useful (0 votes)
3 views

OSLAB6

The document outlines a lab scenario for managing web server processes running Python applications. It includes tasks for running and monitoring processes, managing their priority, terminating processes, and observing resource usage. Key commands and explanations for process attributes, prioritization, and termination signals are provided.

Uploaded by

donkey duu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

OSLAB6

The document outlines a lab scenario for managing web server processes running Python applications. It includes tasks for running and monitoring processes, managing their priority, terminating processes, and observing resource usage. Key commands and explanations for process attributes, prioritization, and termination signals are provided.

Uploaded by

donkey duu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Phy Vathanak Opreting System

Scenario: Web Server Process Management


You are managing a web server hosting several Python-based web applications. Each
application runs as a separate process. Your tasks involve monitoring these processes,
ensuring they don't consume excessive resources, and managing their priorities to
ensure smooth operation of the server.
Lab Tasks
Task 1: Running and Monitoring Processes

1. Setup:
a. Write three Python scripts: cpu_intensive.py, memory_intensive.py, and
long_running.py.

b. Run each script: python3 [script_name].py &

c. Explain what does the command above do?


Run the python script in the background, freeing up the terminal for other tasks.
2. Monitoring:
a. Use ps aux to list the processes.

b. Observe CPU and memory usage with top or htop.


c. Explain each attribute of the process associated with ps aux
USER: The user who owns the process.
PID: The Process ID (unique identifier for each process).
%CPU: The percentage of CPU the process is using.
%MEM: The percentage of memory the process is using.
VSZ: Virtual memory size in kilobytes.
RSS: Resident Set Size (physical memory the process is using in kilobytes).
TTY: The terminal associated with the process (if applicable).
STAT: The process status (e.g., S for sleeping, R for running, Z for zombie).
START: The start time of the process.
TIME: The total CPU time used by the process.
COMMAND: The command that launched the process.
Task 2: Managing Process Priority
3. Prioritization:
a. Identify the PID of cpu_intensive.py.

PID = 9209
b. Lower its priority using renice.
Priority range: -20 ( highest prio) : 19 ( lowest prio )
nice -n 10 python3 cpu_intensive_1.py &
nice -n -1 python3 cpu_intensive_2.py &
renice -n -10 -p PID of cpu_intensive_1.py &
renice -n 5 -p PID cpu_intensive_2.py &
Task 3: Process Termination
4. Termination:
a. Use kill to terminate long_running.py with SIGTERM and SIGKILL.
Using SIGTERM

SIGKILL

b. Explain the differences between SIGTERM and SIGKILL.


SIGTERM: A graceful termination signal. It allows the process to clean up resources before
exiting. The process can choose to handle or ignore it.
SIGKILL: A forceful termination signal. It immediately stops the process without allowing it to
clean up or handle the signal. The process cannot ignore or handle this signal.

Task 4: Resource Management


5. Resource Observation:
a. Determine which script is most resource-intensive using top or htop

cpu_intensive.py : High CPU usage as it performs heavy calculations in a loop.


memory_intensive.py : High memory usage due to creating large lists.
long_running_script : Low resource usage, mainly just printing periodically.

You might also like