Open In App

Python | os.sched_get_priority_min() method

Improve
Improve
Like Article
Like
Save
Share
Report

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_min() method in Python is used to get the minimum priority value for the specified scheduling policy.

Note: This method is only available on some UNIX platforms.

Syntax: os.sched_get_priority_min(policy)

Parameter:
policy The scheduling policy whose minimum 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 minimum priority value for the specified scheduling policy.

Code: Use of os.sched_get_priority_min() method




# Python program to explain os.sched_get_priority_min() method  
  
# importing os module 
import os
  
print("Below are the minimum priority\
value for different scheduling policy") 
  
# Get the minimum priority value for
# first In First Out scheduling policy
# os.SCHED_FIFO constant represents 
# first In First Out scheduling policy
priority_min = os.sched_get_priority_min(os.SCHED_FIFO)
print("First In First Out scheduling policy:", priority_min)
  
# Get the minimum priority value for
# round-robin scheduling policy
# os.SCHED_RR constant represents the
# round-robin scheduling policy
priority_min = os.sched_get_priority_min(os.SCHED_RR)
print("Round-robin scheduling policy:", priority_min)
  
  
# Get the minimum priority value for
# the default scheduling policy
# os.SCHED_OTHER constant represents the
# default scheduling policy.
priority_min = os.sched_get_priority_min(os.SCHED_OTHER)
print("Default scheduling policy.:", priority_min)
  
  
# Get the minimum priority value 
# for scheduling policy for extremely
# low priority background tasks
# os.SCHED_IDLE constant represents the
# scheduling policy for extremely low
# priority background tasks.
priority_min = os.sched_get_priority_min(os.SCHED_IDLE)
print("Scheduling policy for extremely\
low priority background tasks:", priority_min)
  
  
# Get the minimum priority value 
# for scheduling policy for CPU-intensive
# processes that tries to preserve 
# interactivity on the rest of the computer.
# os.SCHED_BATCH constant represents the
# scheduling policy CPU-intensive processes
# that tries to preserve interactivity
# on the rest of the computer.
priority_min = os.sched_get_priority_min(os.SCHED_BATCH)
print("Scheduling policy for CPU-intensive processes:", priority_min)


Output:

Below are the minimum priority value for different scheduling policy
First In First Out scheduling policy: 1
Round-robin scheduling policy: 1
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_min



Last Updated : 25 Jun, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads