Python | os.sched_get_priority_max() method
Last Updated :
25 Jun, 2019
OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality.
OS module contains some methods which provides an interface to the scheduler and used to control how a process is allocated CPU time by the operating system.
os.sched_get_priority_max()
method in Python is used to get the maximum priority value for the specified scheduling policy.
Note: This method is only available on some UNIX platforms.
Syntax: os.sched_get_priority_max(policy)
Parameter:
policy The scheduling policy whose maximum priority value is required.
Below are the scheduling policy constants that can be used as policy parameter value:
- os.SCHED_OTHER: It represents the default scheduling policy.
- os.SCHED_BATCH: It represents the scheduling policy for CPU-intensive processes that tries to preserve interactivity on the rest of the computer.
- os.SCHED_IDLE: It represents the scheduling policy for extremely low priority background tasks.
- os.SCHED_SPORADIC: It represents the scheduling policy for sporadic server programs.
- os.SCHED_FIFO: It represents First In First Out scheduling policy.
- os.SCHED_RR: It represents round-robin scheduling policy.
Return Type: This method returns an integer value which represents the maximum priority value for the specified scheduling policy.
Code: Use of os.sched_get_priority_max() method
import os
print ("Below are the maximum priority\
value for different scheduling policy")
priority_max = os.sched_get_priority_max(os.SCHED_FIFO)
print ( "First In First Out scheduling policy:" , priority_max)
priority_max = os.sched_get_priority_max(os.SCHED_RR)
print ( "Round-robin scheduling policy:" , priority_max)
priority_max = os.sched_get_priority_max(os.SCHED_OTHER)
print ( "Default scheduling policy.:" , priority_max)
priority_max = os.sched_get_priority_max(os.SCHED_IDLE)
print ("Scheduling policy for extremely\
low priority background tasks:", priority_max)
priority_max = os.sched_get_priority_max(os.SCHED_BATCH)
print ( "Scheduling policy for CPU-intensive processes:" , priority_max)
|
Output:
Below are the maximum priority value for different scheduling policy
First In First Out scheduling policy: 99
Round-robin scheduling policy: 99
Default scheduling policy.: 0
Scheduling policy for extremely low priority background tasks: 0
Scheduling policy for CPU-intensive processes: 0
References: https://docs.python.org/3/library/os.html#os.sched_get_priority_max
Share your thoughts in the comments
Please Login to comment...