Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Operating System Concepts: Process Management and Scheduling, Study notes of Operating Systems

An overview of operating system concepts, focusing on processor and user modes, kernels, system calls, and system programs. It explains the system's view of processes and resources, process abstraction, hierarchy, threads, and threading issues. The document also covers process scheduling, including preemptive and non-preemptive scheduling algorithms. It further discusses system calls, their types, and the services they provide, along with system programs and their role in creating an environment for program development and execution. The document also touches on process states, process control blocks, context switching, and thread management, including thread cancellation and signal handling. It concludes with an explanation of process scheduling queues and various scheduling algorithms, such as preemptive and non-preemptive scheduling, including examples and performance considerations. Useful for students studying operating systems and computer architecture.

Typology: Study notes

2024/2025

Available from 05/19/2025

raziya-shiak
raziya-shiak 🇮🇳

5 documents

1 / 24

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
OPERATING SYSTEM-2
Processor and User Modes, Kernels,
System Calls and System Programs, System View of the
Process and Resources, Process Abstraction, Process
Hierarchy, Threads, Threading Issues, Thread Libraries;
Process Scheduling, Non-Preemptive and Preemptive
Scheduling Algorithms.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18

Partial preview of the text

Download Operating System Concepts: Process Management and Scheduling and more Study notes Operating Systems in PDF only on Docsity!

OPERATING SYSTEM- 2

Processor and User Modes, Kernels,

System Calls and System Programs, System View of the

Process and Resources, Process Abstraction, Process

Hierarchy, Threads, Threading Issues, Thread Libraries;

Process Scheduling, Non-Preemptive and Preemptive

Scheduling Algorithms.

1. Write about User Modes and Kernel Modes? - A processor in a computer running Windows has two different modes: user mode and kernel mode. - The processor switches between the two modes depending on what type of code is running on the processor. Applications run in user mode, and core operating system components run in kernel mode. USER Mode If CPU is executing the user applications then CPU will be in the user mode. The User applications are games, media players, text editor, MS Office etc. Executing code in user mode has no ability to directly access some resources like Hard Disk, memory, Printer and other I/O devices. Because, to access these resources we have to use kernel mode through System Call. Note: User mode is also known as safe mode and Restricted mode. Kernel Mode Kernel mode contains OS which has full functionality to access and maintain all the hardware components. Hardware components are RAM, HARD, CPU, printer and other I/O devices. Whenever the system call generate, CPU switch to kernel mode from user mode. System call is executed in kernel mode. After execution of system call it returns back to user mode. Note: kernel mode also known as system, private or supervisory mode, protected mode because user can’t access this area directly.

Watching Movie in windows OS If we want to play movie then we have to double click on that particular video. As, that video exist in main memory and main memory is hardware. So, CPU cannot access the hardware in user mode. System have to request through system call to open the file in main memory. So, OPEN () system call is generated and CPU switch to Kernel mode. Now OS in kernel, open that particular file from main memory. After opening the file CPU switch back to user mode. Now we are watching the movie in user mode. When user want to close the file then CLOSE system call again generated. Real Life example If we go for back to withdraw money. Then the staff of bank is kernel and our command in user mode is withdraw the money. This request is executed by bank staff to withdraw the money. So, without kernel, user can’t proceed. System Call System calls are the calls (functions) that are required to invoke the services provided by the operating system. These calls provide an interface between the user program and the operating system. We call this interface as Application Program Interface. Explanation of System Call As in above diagram, User Applications run in user mode, and operating system run in kernel mode. As OS control all the hardware’s so User cannot access hardware without kernel mode. To access kernel mode user application generate a system call because System call is a source to go to kernel mode. CPU switch in two modes, while working

  • User mode
  • Kernel mode

Services Provided by System Calls:

  1. Process creation and management
  2. Main memory management
  3. File Access, Directory and File system management
  4. Device handling(I/O)
  5. Protection
  6. Networking, etc Types of System Call Process control The process control system call is used to create and manage the processes in the operating system. File management The file management system call controls the file and directory system of the computer. Device management The device management system call is required to control and manage the devices attached to the computer system. Information maintenance The information maintenance system call maintains the information of the computer such as system time, date, etc. Communications A communication call is required to connect your computer over the network. System Programs
  7. Creates an environment for program to develop and execute.
  8. Defines a user interface of operating system.
  9. It satisfies the high-level request of the user program.
  10. Initiates a sequence of system calls for to satisfy a user request.
  11. System program are written in high-level languages only. Types of the System Program There are mainly six types of system programs. These are classified as follows:

3. What is Process abstraction? - Abstraction means hiding the working complexity of the system. The operating system provides a layer of abstraction with the help of OSAL. - OSAL stands for Operating System Abstraction Layer, a set of APIs that a developer can use to quickly develop an application without considering the type of operating system, hardware, and background complexity of the operating system. - The main purpose of abstraction provided by the operating system is to hide the working complexity or technical details of the system. With the help of abstraction, the Operating System provides a separation between hardware and software. - Operating system provides hardware abstraction which allows the system users or developers to develop system-independent applications. - Using a hardware abstraction layer the user processes or system processes can simply use the hardware devices with the help of specific system calls. 4. Explain process Hierarchy? Write about the process and the process state and Process Control Block (PCB) When a process creates another process, then the parent and the child processes tend to associate with each other in certain ways and further. The child process can

also create other processes if required. This parent-child like structure of processes form a hierarchy, called Process Hierarchy. Process: An active program which running now on the Operating System is known as the process. For example, when you want to search something on web then you start a browser. So, this can be process.

  • Stack – A process stores temporary data onto the stack.
  • Heap- Heap is a memory allocated to the process during execution.
  • Data – The data section stores the global variable.
  • Text – The text section includes the program code that has to be executed.

1. Process ID: When a new process is created by the user, the operating system assigns a unique ID So, process-ID will get the values from 0 to N-1. - First process will be given ID0. - Second process will be given ID 1. - It continues till N-1. 2. Process State: A process, from its creation to completion goes through different states. Generally, a process may be present in one of the 5 states during its execution:

3. Process Priority: Process priority is a numeric value that represents the priority of each process. 4. Process Accounting Information: This attribute gives the information of the resources used by that process in its lifetime. For Example: CPU time connection time, etc. 5. Program Counter: The program counter is a pointer that points to the next instruction in the program to be executed. 6. CPU registers: A CPU register is a quickly accessible small-sized location available to the CPU. These registers are stored in virtual memory (RAM). 7. Context Switching: A context switching is a process that involves switching the CPU from one process or task to another. 8. PCB pointer: This field contains the address of the next PCB, which is in ready state. This helps the operating system to hierarchically maintain an easy control flow between parent processes and child processes. 9. List of open files: As the name suggests, It contains information on all the files that are used by that process. 10. Process I/O information: In this field, the list of all the input/output devices which are required by that process during its execution is mentioned.

Kernel level thread The kernel-level thread is implemented by the operating system. The kernel knows about all the threads and manages them. The kernel-level thread offers a system call to create and manage the threads from user-space. Components of Thread A thread has the following three components:

  1. Program Counter
  2. Register Set
  3. Stack space

Types of Threaded process

6. Write about Thread Issues? Threading Issues Following threading issues are: - The fork() and exec() system call - Signal handling - Thread cancelation - Thread Pool 1. fork( ) and exec( ) system calls: The fork() call is used to create a duplicate child process. During a fork( ) call the issue that arises is whether the whole process should be duplicated or just the thread which made the fork( ) call should be duplicated. The exec( ) call replaces the whole process that called it including all the threads in the process with a new program. 2. Thread cancellation: The termination of a thread before its completion is called thread cancellation and the terminated thread is termed as target thread. Thread cancellation is of two types: 1. Asynchronous Cancellation: In asynchronous cancellation, one thread immediately terminates the target thread. 2. Deferred Cancellation: In deferred cancellation, the target thread periodically checks if it should be terminated.

The main thread libraries which are used are given below −

  • POSIX threads − Pthreads, the threads extension of the POSIX standard, may be provided as either a user level or a kernel level library.
  • WIN 32 thread − The windows thread library is a kernel level library available on windows systems.
  • JAVA thread − The JAVA thread API allows threads to be created and managed directly as JAVA programs. 8. Explain process scheduling? Types of CPU Scheduling Algorithms? Process scheduling is an important part of multiprogramming operating systems. It is the process of removing the running task from the processor and selecting another task for processing. Process Scheduling Queues
  1. Job Queue – Whenever any process enters the system its there in job Queue
  2. Ready Queue – Processes in the ready queue waiting for run time are in the ready queue.
  3. Device Queue – Some processes may be waiting some I/O operation, such processes are in the device queue. Different Types of Schedulers
  4. Long-term Scheduler
  5. Short-term Scheduler
  1. Medium-term Scheduler Types of Process Scheduling Algorithms We divided Process Scheduling into following two
  • Preemptive Scheduling – The scheduling in which a running process can be interrupted if a high priority process enters the queue and is allocated to the CPU is called preemptive scheduling. In this case, the current process switches from the running queue to ready queue and the high priority process utilizes the CPU cycle. Examples: – Round Robin, preemptive priority, Shortest Remaining Time First (SRTF), etc. 1. Round Robin (RR) scheduling algorithm
  • Round Robin is the preemptive process scheduling algorithm.
  • Each process is provided a fix time to execute, it is called a quantum.
  • Once a process is executed for a given time period, it is preempted and other process executes for a given time period.
  • Context switching is used to save states of preempted processes.

2. preemptive priority scheduling 1. It is a method of scheduling processes that is based on priority 2. selects the tasks to work as per the priority. 3. Lowest integer value is highest priority. 4. Highest integer value is low priority. EXAMPLE: PID ( PROCESS ID), BT (BURST TIME), AT (ARRIVAL TIME), CT (PROCESS COMPLETION TIME), TAT (TURN AROUND TIME), **WT (WAITING TIME), RT (RESPONSE TIME) PID PRIORITY AT BT CT TAT=CT- AT WT=TAT- BT RT=QUEUEFIRSTVALUE

  • AT P0 3 0 6 - 1=5-1=4-1=3 7 7 - 0=7 7 - 6=1 0 - 0= P1 6 1 2 13 13 - 1=12 12 - 2=10 11 - 1= P2 4 2 4 11 11 - 2=9 9 - 4=5 7 - 2= P3 2 3 1 4 4 - 3=1 1 - 1=0 3 - 3= Gantt Chart P0 P0 P0 P3 P0 P2 P 0 1 2 3 4 7 11 13** Average Turn Around Time=sum of TAT/ =7+12+9+1/ =28. Average Waiting Time=sum of wt/ =1+10+5+0/ =

3. Shortest Remaining Time First (SRTF) Scheduling Algorithm The SRTF scheduling algorithm is the preemptive version of the SJF scheduling algorithm in OS. This calls for the job with the shortest burst time remaining to be executed first, and it keeps preempting jobs on the basis of burst time remaining in ascending order.