Vous êtes sur la page 1sur 4

Group B Assignment 4

Title : C++ Program to assign nice values to processes and dynamically monitor
them.

Assignment B4
A.

Aim/Problem Statement
Write a C++ Program to assign nice values to processes and dynamically monitor them.

B.

Index Terms
nice, setpriority, process, getpriority

C.

Mathematical Model
Let St be the system and it consists of
St={{I},{o},{S},{F},{Fx}}
I: Set of Inputs
O: Set of outputs
S: Set of success outputs
F: Set of failure conditions
Fx: Set of processing functions
I={PId,NI}
W={PRIO_PROCESS,PRIO_PGRP,PRIO_USER}
F(g)= PRIORITY
=0

if g W

F(s)= PRIORITY +NI


=-1

if s W or NI>19 or NI<-20

F(p) =PID
O= {PID, PRIORITY, PRIORITY+NI}
S= {PID, PRIORITY, PRIORITY+NI}
F={0,-1}

D.

State Diagram

E.

Theory
Process: A Process is an instance of running a program. Program in execution is called as
a process. UNIX is a timesharing system, which means that the processes take turns
running.
getpriority ( ) : It is included in sys/resource.h and sys/time.h. The getpriority() call is used to
see the priority of the processes.

setpriority ( ) : It is also included in sys/resource.h and sys/time.h. The setpriority() call


sets the priorities of all of the specified processes to the specified value. Only the
superuser may lower priorities.
nice command :
It is used to start process with modified scheduling priority / nicenesses. Users can only
change the nice value of processes which they own.
1. User cannot start processes with nice values less than 20
2. User cannot lower the nice values of their processes after they've raised them.
3. As usual root has full access to renice command.
4. The default priority is 0.

renice command:
renice command is used to change the priority of a process that's already running. Nice
values ranges from -20 (high nice value) through 19 (the least nice value). The default
behavior is to increase the niceness by 10.

F.

Conclusion: Hence to assign and to monitor the nice value for a process is done
successfully.

Vous aimerez peut-être aussi