This program implements the First Come First Serve (FCFS) CPU scheduling algorithm in C. It takes the arrival time and service time of each process as input, calculates the start time, finish time, waiting time and turnaround time of each process, and outputs these values along with the average waiting time and average turnaround time. The processes are scheduled in the order of their arrival, with no preemption, following the FCFS principle.
This Operating System lab manual is designed strictly according to BPUT Syllabus.Any suggestions or comments are well come at neelamani.samal@gmail.com
Operating Systems Process Scheduling Algorithmssathish sak
The document discusses various CPU scheduling algorithms used in operating systems including first-come, first-served (FCFS), round robin (RR), shortest job first (SJF), and shortest remaining time first (SRTF). It explains the assumptions, goals, and tradeoffs of each algorithm such as minimizing response time, maximizing throughput, and ensuring fairness. Examples are provided to illustrate how each algorithm works and its performance compared to others under different conditions involving job lengths. Predicting future job lengths is also discussed as it can impact the performance of algorithms like SRTF.
This document discusses the complexity of algorithms and the tradeoff between algorithm cost and time. It defines algorithm complexity as a function of input size that measures the time and space used by an algorithm. Different complexity classes are described such as polynomial, sub-linear, and exponential time. Examples are given to find the complexity of bubble sort and linear search algorithms. The concept of space-time tradeoffs is introduced, where using more space can reduce computation time. Genetic algorithms are proposed to efficiently solve large-scale construction time-cost tradeoff problems.
A document about deadlocks in operating systems is summarized as follows:
1. A deadlock occurs when a set of processes form a circular chain where each process is waiting for a resource held by the next process in the chain. The four conditions for deadlock are mutual exclusion, hold and wait, no preemption, and circular wait.
2. Deadlocks can be modeled using a resource allocation graph where processes and resources are vertices and edges represent resource requests. A cycle in the graph indicates a potential deadlock.
3. Methods for handling deadlocks include prevention, avoidance, and detection/recovery. Prevention ensures deadlock conditions cannot occur while avoidance allows the system to dynamically verify new allocations will not
This document provides an overview of distributed operating systems, including:
- A distributed operating system runs applications on multiple connected computers that look like a single centralized system to users. It distributes jobs across processors for efficient processing.
- Early research began in the 1950s with systems like DYSEAC and Lincoln TX-2 that exhibited distributed control features. Major development occurred from the 1970s-1990s, though few systems achieved commercial success.
- Key considerations in designing distributed operating systems include transparency, inter-process communication, process management, resource management, reliability, and performance. Examples of distributed operating systems include Windows Server and Linux-based systems.
There are several mechanisms for inter-process communication (IPC) in UNIX systems, including message queues, shared memory, and semaphores. Message queues allow processes to exchange data by placing messages into a queue that can be accessed by other processes. Shared memory allows processes to communicate by declaring a section of memory that can be accessed simultaneously. Semaphores are used to synchronize processes so they do not access critical sections at the same time.
The document discusses process synchronization and solutions to the critical section problem. It introduces the producer-consumer problem as an example that requires synchronization. The critical section problem aims to ensure that only one process at a time can be executing shared code or accessing shared data. Peterson's algorithm provides a solution for two processes using shared variables. Hardware synchronization methods like mutex locks and semaphores provide atomic primitives to synchronize processes. Semaphores use wait() and signal() operations to control access to shared resources without busy waiting.
This lecture covers process and thread concepts in operating systems including scheduling criteria and algorithms. It discusses key process concepts like process state, process control block and CPU scheduling. Common scheduling algorithms like FCFS, SJF, priority and round robin are explained. Process scheduling queues and the producer-consumer problem are also summarized. Evaluation methods for scheduling algorithms like deterministic modeling, queueing models and simulation are briefly covered.
This Operating System lab manual is designed strictly according to BPUT Syllabus.Any suggestions or comments are well come at neelamani.samal@gmail.com
Operating Systems Process Scheduling Algorithmssathish sak
The document discusses various CPU scheduling algorithms used in operating systems including first-come, first-served (FCFS), round robin (RR), shortest job first (SJF), and shortest remaining time first (SRTF). It explains the assumptions, goals, and tradeoffs of each algorithm such as minimizing response time, maximizing throughput, and ensuring fairness. Examples are provided to illustrate how each algorithm works and its performance compared to others under different conditions involving job lengths. Predicting future job lengths is also discussed as it can impact the performance of algorithms like SRTF.
This document discusses the complexity of algorithms and the tradeoff between algorithm cost and time. It defines algorithm complexity as a function of input size that measures the time and space used by an algorithm. Different complexity classes are described such as polynomial, sub-linear, and exponential time. Examples are given to find the complexity of bubble sort and linear search algorithms. The concept of space-time tradeoffs is introduced, where using more space can reduce computation time. Genetic algorithms are proposed to efficiently solve large-scale construction time-cost tradeoff problems.
A document about deadlocks in operating systems is summarized as follows:
1. A deadlock occurs when a set of processes form a circular chain where each process is waiting for a resource held by the next process in the chain. The four conditions for deadlock are mutual exclusion, hold and wait, no preemption, and circular wait.
2. Deadlocks can be modeled using a resource allocation graph where processes and resources are vertices and edges represent resource requests. A cycle in the graph indicates a potential deadlock.
3. Methods for handling deadlocks include prevention, avoidance, and detection/recovery. Prevention ensures deadlock conditions cannot occur while avoidance allows the system to dynamically verify new allocations will not
This document provides an overview of distributed operating systems, including:
- A distributed operating system runs applications on multiple connected computers that look like a single centralized system to users. It distributes jobs across processors for efficient processing.
- Early research began in the 1950s with systems like DYSEAC and Lincoln TX-2 that exhibited distributed control features. Major development occurred from the 1970s-1990s, though few systems achieved commercial success.
- Key considerations in designing distributed operating systems include transparency, inter-process communication, process management, resource management, reliability, and performance. Examples of distributed operating systems include Windows Server and Linux-based systems.
There are several mechanisms for inter-process communication (IPC) in UNIX systems, including message queues, shared memory, and semaphores. Message queues allow processes to exchange data by placing messages into a queue that can be accessed by other processes. Shared memory allows processes to communicate by declaring a section of memory that can be accessed simultaneously. Semaphores are used to synchronize processes so they do not access critical sections at the same time.
The document discusses process synchronization and solutions to the critical section problem. It introduces the producer-consumer problem as an example that requires synchronization. The critical section problem aims to ensure that only one process at a time can be executing shared code or accessing shared data. Peterson's algorithm provides a solution for two processes using shared variables. Hardware synchronization methods like mutex locks and semaphores provide atomic primitives to synchronize processes. Semaphores use wait() and signal() operations to control access to shared resources without busy waiting.
This lecture covers process and thread concepts in operating systems including scheduling criteria and algorithms. It discusses key process concepts like process state, process control block and CPU scheduling. Common scheduling algorithms like FCFS, SJF, priority and round robin are explained. Process scheduling queues and the producer-consumer problem are also summarized. Evaluation methods for scheduling algorithms like deterministic modeling, queueing models and simulation are briefly covered.
This document discusses thread scheduling in operating systems. It defines threads as the basic unit of CPU utilization and describes different types of threads like user-level and kernel-level threads. It explains that thread scheduling is needed to exploit parallelism in multiprocessor systems. Common approaches to thread scheduling include load sharing, dedicated processor assignment, and dynamic scheduling. It provides examples of thread scheduling in Solaris, Linux, and Windows XP operating systems.
Unix was created in 1969 by Ken Thompson at Bell Labs to allow multiple users to access a computer simultaneously. It features a multi-user design, hierarchical file system, and shell interface. The kernel handles memory management, process scheduling, and device interactions to enable these features. Common Unix commands like cat, ls, cp and rm allow users to work with files and directories from the shell. File permissions and ownership are managed through inodes to control access across users.
1. Process management is an integral part of operating systems for allocating resources, enabling information sharing, and protecting processes. The OS maintains data structures describing each process's state and resource ownership.
2. Processes go through discrete states and events can cause state changes. Scheduling selects processes to run from ready, device, and job queues using algorithms like round robin, shortest job first, and priority scheduling.
3. CPU scheduling aims to maximize utilization and throughput while minimizing waiting times using criteria like response time, turnaround time, and fairness between processes.
INTRODUCTIONTO OPERATING SYSTEM
What is an Operating System?
Mainframe Systems
Desktop Systems
Multiprocessor Systems
Distributed Systems
Clustered System
Real -Time Systems
Handheld Systems
Computing Environments
Deadlocks-An Unconditional Waiting Situation in Operating System. We must make sure of This concept well before understanding deep in to Operating System. This PPT will understands you to get how the deadlocks Occur and how can we Detect, avoid and Prevent the deadlocks in Operating Systems.
The document provides an overview of common Linux commands, including commands for executing other commands, navigating directories, listing and copying files, managing users and permissions, searching for files, processing text, managing archives, and compressing files. Examples are given for commands like ls, cd, cp, mv, rm, who, echo, alias, awk, chown, diff, grep, pushd, kill, df, cat, tar, gzip, su. Brief descriptions are provided for most commands and references are given at the end for additional Linux resources.
Case study of windows a product of microsoft including the history and related to operating system with MS-DOS its scheduling, networking, performance, etc. It also contains the windows architecture, it's system components like kernel, and scheduling through threads in windows.
The document discusses various CPU scheduling algorithms including first come first served, shortest job first, priority, and round robin. It describes the basic concepts of CPU scheduling and criteria for evaluating algorithms. Implementation details are provided for shortest job first, priority, and round robin scheduling in C++.
The document discusses memory management techniques used in operating systems. It describes logical vs physical addresses and how relocation registers map logical addresses to physical addresses. It covers contiguous and non-contiguous storage allocation, including paging and segmentation. Paging divides memory into fixed-size frames and pages, using a page table and translation lookaside buffer (TLB) for address translation. Segmentation divides memory into variable-sized segments based on a program's logical structure. Virtual memory and demand paging are also covered, along with page replacement algorithms like FIFO, LRU and optimal replacement.
Linux uses a preemptive multilevel feedback queue scheduling algorithm. Processes have both static priorities based on nice values and dynamic priorities based on recent CPU usage. The scheduler selects from two lists of active and expired processes using their dynamic priorities. It also performs load balancing across CPU runqueues to improve performance on multiprocessor systems. System calls like setpriority(), sched_setscheduler(), and sched_yield() allow modifying process priorities and scheduling policies.
The document discusses different types of matching techniques including pattern matching, partial matching, and fuzzy matching. Pattern matching involves comparing two structures and testing for equality between corresponding parts. Partial matching is used when complete matching is inappropriate, such as when meaning is the same but terminology differs. Fuzzy matching allows for approximate string matching and is useful when data may be corrupted by noise.
LR parsing allows parsers to see the entire right-hand side of a rule and perform lookahead, allowing it to handle a wider range of grammars than LL parsing. The document provides an example of LR parsing a simple expression grammar. It demonstrates the steps of building the LR parsing items, closure, and goto functions to generate the LR parsing table from the grammar. LR parsing tables contain the states, symbols, and parsing actions (reduce, shift, accept).
Unix is a multi-user, multi-tasking operating system that was first created in 1969 at Bell Labs. It allows many users to use the system simultaneously running multiple programs. Linux originated in 1991 as a personal project and is now a free, open source Unix-like operating system. It features multi-tasking, virtual memory, networking and more. Linux is widely used for servers, workstations, internet services and more due to its low cost, stability, and reliability compared to other operating systems.
Here is a potential solution to the problem in C++:
#include <iostream>
using namespace std;
int main() {
int num1, num2, num3;
cout << "Enter three numbers: ";
cin >> num1 >> num2 >> num3;
int total = num1 + num2 + num3;
float average = total / 3.0;
cout << "The numbers entered were: " << num1 << ", " << num2 << ", " << num3 << endl;
cout << "Their average is: " << average;
return 0;
}
Some key points:
- Use cin to input the 3 numbers from the
Worst-case analysis is sometimes overly pessimistic.
Amortized analysis of an algorithm involves computing the maximum total number of all operations on the various data structures.
Amortized cost applies to each operation, even when there are several types of operations in the sequence.
In amortized analysis, time required to perform a sequence of data structure operations is averaged over all the successive operations performed. That is, a large cost of one operation is spread out over many operations (amortized), where the others are less expensive.
Therefore, amortized anaysis can be used to show that the average cost of an operation is small, if one averages over a sequence of operations, even though one of the single operations might be very expensive.
This document provides an overview of concurrency in Python using multiprocessing and threading. It begins by introducing the speaker and defining key terms like concurrency, threads, and processes. It then discusses the benefits and use cases of threads versus processes. The document also covers the Global Interpreter Lock (GIL) in Python and how multiprocessing can help avoid it. It provides an example benchmark showing multiprocessing can significantly outperform threading for CPU-bound tasks. Finally, it discusses key aspects of Python's multiprocessing module like Process, Queue, Pool, and Manager classes.
The document provides an overview of parallel processing and multiprocessor systems. It discusses Flynn's taxonomy, which classifies computers as SISD, SIMD, MISD, or MIMD based on whether they process single or multiple instructions and data in parallel. The goals of parallel processing are to reduce wall-clock time and solve larger problems. Multiprocessor topologies include uniform memory access (UMA) and non-uniform memory access (NUMA) architectures.
This document provides an overview and instructions for basic commands and operations in the UNIX operating system. It discusses the kernel and shell structure of UNIX, the file hierarchy, and common commands for file manipulation, processing, and navigation. It also provides a tutorial on the vi text editor, including instructions for basic cursor movement, text insertion, changing, and deletion.
This document contains the code for simulating different CPU scheduling algorithms including FCFS, SJF, and priority scheduling. It includes the code to input process details like name, arrival time, and burst time. It then calculates start time, waiting time, turnaround time, and response time for each process. The average waiting time and average turnaround time are also calculated at the end for each algorithm.
This document discusses thread scheduling in operating systems. It defines threads as the basic unit of CPU utilization and describes different types of threads like user-level and kernel-level threads. It explains that thread scheduling is needed to exploit parallelism in multiprocessor systems. Common approaches to thread scheduling include load sharing, dedicated processor assignment, and dynamic scheduling. It provides examples of thread scheduling in Solaris, Linux, and Windows XP operating systems.
Unix was created in 1969 by Ken Thompson at Bell Labs to allow multiple users to access a computer simultaneously. It features a multi-user design, hierarchical file system, and shell interface. The kernel handles memory management, process scheduling, and device interactions to enable these features. Common Unix commands like cat, ls, cp and rm allow users to work with files and directories from the shell. File permissions and ownership are managed through inodes to control access across users.
1. Process management is an integral part of operating systems for allocating resources, enabling information sharing, and protecting processes. The OS maintains data structures describing each process's state and resource ownership.
2. Processes go through discrete states and events can cause state changes. Scheduling selects processes to run from ready, device, and job queues using algorithms like round robin, shortest job first, and priority scheduling.
3. CPU scheduling aims to maximize utilization and throughput while minimizing waiting times using criteria like response time, turnaround time, and fairness between processes.
INTRODUCTIONTO OPERATING SYSTEM
What is an Operating System?
Mainframe Systems
Desktop Systems
Multiprocessor Systems
Distributed Systems
Clustered System
Real -Time Systems
Handheld Systems
Computing Environments
Deadlocks-An Unconditional Waiting Situation in Operating System. We must make sure of This concept well before understanding deep in to Operating System. This PPT will understands you to get how the deadlocks Occur and how can we Detect, avoid and Prevent the deadlocks in Operating Systems.
The document provides an overview of common Linux commands, including commands for executing other commands, navigating directories, listing and copying files, managing users and permissions, searching for files, processing text, managing archives, and compressing files. Examples are given for commands like ls, cd, cp, mv, rm, who, echo, alias, awk, chown, diff, grep, pushd, kill, df, cat, tar, gzip, su. Brief descriptions are provided for most commands and references are given at the end for additional Linux resources.
Case study of windows a product of microsoft including the history and related to operating system with MS-DOS its scheduling, networking, performance, etc. It also contains the windows architecture, it's system components like kernel, and scheduling through threads in windows.
The document discusses various CPU scheduling algorithms including first come first served, shortest job first, priority, and round robin. It describes the basic concepts of CPU scheduling and criteria for evaluating algorithms. Implementation details are provided for shortest job first, priority, and round robin scheduling in C++.
The document discusses memory management techniques used in operating systems. It describes logical vs physical addresses and how relocation registers map logical addresses to physical addresses. It covers contiguous and non-contiguous storage allocation, including paging and segmentation. Paging divides memory into fixed-size frames and pages, using a page table and translation lookaside buffer (TLB) for address translation. Segmentation divides memory into variable-sized segments based on a program's logical structure. Virtual memory and demand paging are also covered, along with page replacement algorithms like FIFO, LRU and optimal replacement.
Linux uses a preemptive multilevel feedback queue scheduling algorithm. Processes have both static priorities based on nice values and dynamic priorities based on recent CPU usage. The scheduler selects from two lists of active and expired processes using their dynamic priorities. It also performs load balancing across CPU runqueues to improve performance on multiprocessor systems. System calls like setpriority(), sched_setscheduler(), and sched_yield() allow modifying process priorities and scheduling policies.
The document discusses different types of matching techniques including pattern matching, partial matching, and fuzzy matching. Pattern matching involves comparing two structures and testing for equality between corresponding parts. Partial matching is used when complete matching is inappropriate, such as when meaning is the same but terminology differs. Fuzzy matching allows for approximate string matching and is useful when data may be corrupted by noise.
LR parsing allows parsers to see the entire right-hand side of a rule and perform lookahead, allowing it to handle a wider range of grammars than LL parsing. The document provides an example of LR parsing a simple expression grammar. It demonstrates the steps of building the LR parsing items, closure, and goto functions to generate the LR parsing table from the grammar. LR parsing tables contain the states, symbols, and parsing actions (reduce, shift, accept).
Unix is a multi-user, multi-tasking operating system that was first created in 1969 at Bell Labs. It allows many users to use the system simultaneously running multiple programs. Linux originated in 1991 as a personal project and is now a free, open source Unix-like operating system. It features multi-tasking, virtual memory, networking and more. Linux is widely used for servers, workstations, internet services and more due to its low cost, stability, and reliability compared to other operating systems.
Here is a potential solution to the problem in C++:
#include <iostream>
using namespace std;
int main() {
int num1, num2, num3;
cout << "Enter three numbers: ";
cin >> num1 >> num2 >> num3;
int total = num1 + num2 + num3;
float average = total / 3.0;
cout << "The numbers entered were: " << num1 << ", " << num2 << ", " << num3 << endl;
cout << "Their average is: " << average;
return 0;
}
Some key points:
- Use cin to input the 3 numbers from the
Worst-case analysis is sometimes overly pessimistic.
Amortized analysis of an algorithm involves computing the maximum total number of all operations on the various data structures.
Amortized cost applies to each operation, even when there are several types of operations in the sequence.
In amortized analysis, time required to perform a sequence of data structure operations is averaged over all the successive operations performed. That is, a large cost of one operation is spread out over many operations (amortized), where the others are less expensive.
Therefore, amortized anaysis can be used to show that the average cost of an operation is small, if one averages over a sequence of operations, even though one of the single operations might be very expensive.
This document provides an overview of concurrency in Python using multiprocessing and threading. It begins by introducing the speaker and defining key terms like concurrency, threads, and processes. It then discusses the benefits and use cases of threads versus processes. The document also covers the Global Interpreter Lock (GIL) in Python and how multiprocessing can help avoid it. It provides an example benchmark showing multiprocessing can significantly outperform threading for CPU-bound tasks. Finally, it discusses key aspects of Python's multiprocessing module like Process, Queue, Pool, and Manager classes.
The document provides an overview of parallel processing and multiprocessor systems. It discusses Flynn's taxonomy, which classifies computers as SISD, SIMD, MISD, or MIMD based on whether they process single or multiple instructions and data in parallel. The goals of parallel processing are to reduce wall-clock time and solve larger problems. Multiprocessor topologies include uniform memory access (UMA) and non-uniform memory access (NUMA) architectures.
This document provides an overview and instructions for basic commands and operations in the UNIX operating system. It discusses the kernel and shell structure of UNIX, the file hierarchy, and common commands for file manipulation, processing, and navigation. It also provides a tutorial on the vi text editor, including instructions for basic cursor movement, text insertion, changing, and deletion.
This document contains the code for simulating different CPU scheduling algorithms including FCFS, SJF, and priority scheduling. It includes the code to input process details like name, arrival time, and burst time. It then calculates start time, waiting time, turnaround time, and response time for each process. The average waiting time and average turnaround time are also calculated at the end for each algorithm.
This document contains 8 C programming code examples demonstrating various scheduling algorithms:
1. First Come First Serve scheduling
2. Non-preemptive Shortest Job First scheduling
3. Round Robin scheduling
4. Priority scheduling
5. Banker's algorithm for deadlock avoidance
6. Producer-consumer problem synchronization
7. Dekker's algorithm for mutual exclusion
Each program example includes comments explaining the algorithm and includes functions to calculate waiting times, turnaround times, and other metrics.
The document describes four different CPU scheduling algorithms: First Come First Serve (FCFS), Shortest Job First (preemptive and non-preemptive), Priority scheduling (non-preemptive), and Round Robin. For each algorithm, pseudocode is provided to simulate the scheduling of processes and calculate metrics like waiting time and turnaround time. The FCFS algorithm calculates these metrics in a straightforward manner based on arrival time and burst time of each process. Shortest Job First simulates sorting processes by burst time and calculating wait times and turnaround times accordingly. Priority scheduling first sorts by priority then calculates metrics. Round Robin simulates time slicing by allocating a time quantum to each process in turn.
Human:
This document contains programs and algorithms for simulating different CPU scheduling algorithms like FCFS, SJF, Priority and Round Robin. It also contains a program for implementing the Producer-Consumer problem using semaphores and an algorithm for implementing optimal page replacement.
This document provides information about an OS lab manual, including definitions of operating systems, computer system components, Windows 2000 architecture and components, and other topics like LDAP, DNS, and Active Directory. Specifically, it defines operating systems, their goals, and components. It describes the Windows 2000 architecture in layers and subsystems. It also explains the Windows 2000 kernel, executive, and subsystems like object manager, virtual memory manager, and process manager.
The document discusses the history and development of artificial intelligence over the past 70 years, from the earliest concepts and experiments in computer-based problem solving to recent advances in machine learning using neural networks. It outlines some of the key milestones in AI research and highlights areas that still present challenges for researchers today.
This lab experiment aims to develop a data flow diagram (DFD) model for a given project. A DFD model graphically depicts the flow of data through various processes in a system. It includes level-0, level-1 DFDs and a data dictionary. A level-0 DFD shows the system's context and major processes, while level-1 diagrams provide more detail by decomposing high-level processes. The data dictionary defines all data elements in the DFDs. Developing a balanced DFD model involves matching input/output data between diagram levels. This experiment guides students through drawing DFDs and defining a data dictionary to model the data flow in a system.
1. The document provides a lab manual for computer networks and operating systems labs containing 8 programs to implement various networking and security algorithms.
2. The programs include implementing data link layer framing methods, CRC polynomials, Dijkstra's shortest path algorithm, distance vector routing, DES encryption, breaking the DES code, and RSA encryption/decryption.
3. The document contains instructions for 8 programs to implement computer network and security algorithms as part of a lab course covering topics like data link layer, routing, encryption, and public key cryptography.
The document provides an overview of a Linux Administration training program that covers topics such as Linux history, basics, file systems, users and permissions, processes, shells, text processing tools, and package management. It also lists various courses offered in areas like databases, networking, servers, and programming languages.
Fermentation technology, Bioprocess Principles, History of Industrial Biotechnology, Bioreactor Principles, Bioreactor Design, Parameters to be monitored in Bioreactor, Fermentation Technology, Agitation and Mixing, Baffles
This document provides guidance for Linux administration practicals, including:
- An index of 17 practical topics ranging from basic Linux commands to configuring mail services.
- Detailed instructions for Practical 1 on basic commands like cat, mkdir, cp, and editors like vi. It provides an example directory and file structure to create.
- An overview of Practical 2 on installing Red Hat Linux, including selecting installation options and partitioning the hard drive to make space.
- Descriptions of changing file permissions using both binary and symbolic modes with chmod, and decoding permission codes from the ls command.
- An explanation of the different modes in the vi editor like command, insert, and ex modes,
- A bioreactor is a device used to grow or cultivate cells, tissues or microorganisms. It provides a controlled environment for biochemical reactions and processes involving organisms or their components to produce desired products.
- The document discusses different types of bioreactors including stirred tank, air lift, bubble column, packed bed, fluidized bed and trickle bed reactors. It also covers plant-based bioreactors like seed-based, suspension cultures and hairy root systems.
- Bioreactors are designed based on criteria like the cell system used, hydrodynamics, mass transfer, reaction kinetics, genetic stability, control of environment and scale-up potential. Photobioreactors for cultivating algae are also summarized.
This document provides an overview of virtual memory concepts including segmentation, paging, virtual addresses, linear addresses, physical addresses, page tables, and page directories. It also describes initializing memory management structures like pages and page tables during boot up. Finally, it outlines interfaces for key virtual memory functions like walking the page table, inserting/removing pages, and looking up the physical page for a virtual address.
This document provides instructions for various exercises to be completed as part of an Operating Systems lab manual. It includes exercises on system calls like fork, exec, wait; I/O system calls; simulating commands like ls and grep; scheduling algorithms like FCFS, SJF, priority, round robin; inter-process communication using shared memory, pipes, message queues; the producer-consumer problem using semaphores; and memory management schemes including paging, segmentation, and file allocation techniques. Example code is provided for implementing different memory management algorithms using concepts like free space list, allocated space list, and block merging.
GUN Make is a tool used to automate the building of executables from source code. It determines which files need to be recompiled based on timestamps and builds the necessary targets. Rules define dependencies and commands to transform files. Variables, macros, conditionals, and functions allow for complex logic and reuse in the makefile. Includes allow splitting makefiles into modular pieces.
Operating System Tutoring #1.
by Aerosystem Software Lab. @ Korea Aerospace Univ.
This is tutoring slide for the students who were not understood well about operating system or fundamentals of computer engineering. This slide may has some misconceptions or inappropriate examples. Any feedback is welcomed.
운영체제 튜터링 #1.
- 항공 소프트웨어 연구실 @ 한국항공대학교
본 슬라이드는 튜터링 강의자료로, 운영체제에 대한 개념이나 컴퓨터공학 기초지식이 부족한 학생들을 기준으로 작성하였습니다. 본 슬라이드에 일부 잘못된 개념이나 부적절한 예시가 포함되어 있을 수도 있습니다. 피드백 환영합니다.
This document outlines the workflow process and structure for encoding video and audio files using FFmpeg. It provides a 10 step standard operating procedure (SOP) for encoding files that includes: 1) including headers, 2) linking libraries, 3) setting up output format, 4) preparing codec structures, 5) setting up video codec, 6) setting up audio codec, 7) opening file descriptor and writing header, 8) writing data packets, 9) closing file descriptor, and 10) calculating presentation timestamp (PTS) values.
The document provides an overview of SSL and OpenSSL. It discusses generating keys and certificates, setting up SSL contexts, creating secure connections, reading/writing data, and handling errors. It also provides code snippets for an echo client and server. The echo server loads a certificate, sets up a listening BIO, accepts connections, and performs handshakes. The handshake process involves a client sending a "hello" message and the server responding with its own parameters to establish encryption.
Linux can be downloaded for free and was created to be an open source version of UNIX; it discusses how to install Linux by booting from a CD-ROM or making installation floppies, and then explains how to configure aspects of Linux like software installation and permissions. The document also provides an overview of common Linux commands for navigating and managing the file system, copying/moving files, and uninstalling a Linux operating system by removing it from the boot loader menu.
Linux can be downloaded for free from the internet with no registration fees or costs. It was created by Linus Torvalds as a freely available version of UNIX. Installing Linux involves checking hardware compatibility, repartitioning disks if needed, and booting from an installation CD or floppy disks. Basic installation kits include README files, boot disk images, and packages for common software. Configuring Linux allows customizing settings like installing additional software repositories. Common Linux commands allow navigating and managing the file system and permissions. Uninstalling Linux mainly involves removing it from the boot loader menu rather than deleting its files.
Linux is an open-source operating system used widely for servers and can also be installed on desktops and embedded devices. It uses a modular kernel called Linux and source code is freely available under licenses like GPL. Common Linux distributions include Red Hat, Debian, Ubuntu and others. The Apache web server is widely used open-source software that helped popularize the World Wide Web and can be configured using directives in configuration files.
This document provides a cheat sheet of common Linux commands and their usage. It covers basic file operations like copying, moving, deleting files and directories. It also includes commands for viewing files, compressing/decompressing files, finding files, remote access, and getting system information. The commands are explained over 3 pages with examples of proper syntax and usage for each one.
The document provides instructions for various UNIX commands. It begins by listing commands for working with files like ls, more, emacs, mv, cp, rm, diff, and chmod. It also covers file compression with gzip and gunzip, printing files with lpr, and working with directories using mkdir, cd, and pwd. Additional commands covered find files using ff and grep, send messages with write, and email with elm. The document concludes with commands for managing processes like ps and kill, checking disk usage with du and quota, and viewing login history with last.
The e-book covers some of the really cool ways on how to go about using Linux from Terminal making your daily work much more efficient, less time consuming and of course geeky.
The document provides an overview of the Linux filesystem, including its hierarchical tree structure with common subdirectories like /bin, /home, and /usr. It discusses useful commands for navigating the filesystem like cd, pwd, and running privileged commands with sudo. The document also compares the Linux and Windows filesystem structures and file types. It introduces package management with apt-get and the power of pipes in Linux.
The structure of Linux - Introduction to Linux for bioinformaticsBITS
This 3th slide deck of the training 'Introduction to linux for bioinformatics' gives a broad overview of the file system structure of linux. We very gently introducte the command line in this presentation.
This document provides instructions on installing Linux, including collecting hardware information beforehand, preparing disk partitions, booting from CD-ROM, continuing the installation process by preparing filesystems and installing packages, and basic parts of an installation kit like README files, boot disk images, and the installation CD-ROM. It also covers uninstalling or removing software packages using either the graphical Synaptic tool or command line apt-get commands. Basic Linux commands like mkdir, cd, pwd, rmdir, chown, chmod, ls, and cp are described.
The document provides instructions on installing Linux, including collecting hardware information before installing, preparing disk partitions, installing from a CD-ROM, and basic package management tools for installing, upgrading, and removing software.
The document provides an overview of common Linux commands, including:
- cd to change directories
- ls to list directory contents
- mkdir to create directories
- pwd to print the working directory
- rm to remove files
- rmdir to remove directories
- cp to copy files
- find to locate files
- more and less to view file contents
- vi as a basic text editor
- ps to view running processes
- kill to terminate processes
CompTIA Linux+ Powered by LPI certifies foundational skills and knowledge of Linux. With Linux being the central operating system for much of the world’s IT infrastructure, Linux+ is an essential credential for individuals working in IT, especially those on the path of a Web and software development career. With CompTIA’s Linux+ Powered by LPI certification, you’ll acquire the fundamental skills and knowledge you need to successfully configure, manage and troubleshoot Linux systems. Recommended experience for this certification includes CompTIA A+, CompTIA Network+ and 12 months of Linux admin experience. No prerequisites required.
Linux is a widely used open-source operating system that can run on desktops, servers, and embedded devices. It includes basic commands like cal, date, cd, and cat. The document also provides overviews of installing and configuring the Apache web server, PHP, and MySQL to set up a basic LAMP stack on a Linux system.
Power point on linux commands,appache,php,mysql,html,css,web 2.0venkatakrishnan k
Linux is a widely used open-source operating system that can run on desktops, servers, and embedded devices. The document provides basic commands for Linux like cal to view a calendar, date to check the date and time, and cd to change directories. It also gives an overview of installing and configuring web servers like Apache and PHP as well as databases like MySQL on a Linux system.
This document provides an overview of shell scripting concepts including:
1) Shell scripting allows running lists of commands through a shell interpreter to perform tasks like file manipulation and text printing.
2) Popular shell types include bash, csh, ksh, and tcsh.
3) Benefits include reusability, availability on all systems, readability, and power through combining with tools like awk, grep and sed.
4) The document then covers bash scripting basics like variables, conditionals, loops, functions, arrays, dictionaries, and options to control shell behavior.
This document provides an overview and introduction to the hardware, software, and file structure of the EduBook device. It discusses the hardware components, how to open the case and access internal parts. It then summarizes the available operating systems, describes the Linux file structure and key directories. The document outlines software options like browsers and office applications that are preinstalled. It concludes with some tips on software issues, advanced options for running Windows programs in Wine, and contact information.
This document provides an introduction to the Linux operating system. It discusses that Linux is an open-source operating system based on Unix, and is commonly used over other operating systems due to its low cost, visible source code, and support for open-sourcing applications. The document then covers basic Linux commands for getting system information, navigating directories, manipulating files and getting command help. It also discusses techniques like autocompletion, command history, and wildcards to help users work more efficiently in the Linux terminal.
This document provides an outline for a lecture on basic UNIX commands. It covers commands for file management, printing, finding files, checking information about users, managing processes, connecting to other systems, and more. The lecture was prepared by Simonas Kareiva for students in the Department of Computer Science at Vilnius University.
This document provides a beginner's guide to learning Linux. It covers topics such as what Linux is, understanding files and folders, users and permissions, the root user, opening a terminal, basic commands like ls, cd, pwd, and tar for archiving files. The guide explains important Linux concepts and provides examples of common commands to get started using the Linux command line.
How to Create a Stage or a Pipeline in Odoo 17 CRMCeline George
Using CRM module, we can manage and keep track of all new leads and opportunities in one location. It helps to manage your sales pipeline with customizable stages. In this slide let’s discuss how to create a stage or pipeline inside the CRM module in odoo 17.
Get Success with the Latest UiPath UIPATH-ADPV1 Exam Dumps (V11.02) 2024yarusun
Are you worried about your preparation for the UiPath Power Platform Functional Consultant Certification Exam? You can come to DumpsBase to download the latest UiPath UIPATH-ADPV1 exam dumps (V11.02) to evaluate your preparation for the UIPATH-ADPV1 exam with the PDF format and testing engine software. The latest UiPath UIPATH-ADPV1 exam questions and answers go over every subject on the exam so you can easily understand them. You won't need to worry about passing the UIPATH-ADPV1 exam if you master all of these UiPath UIPATH-ADPV1 dumps (V11.02) of DumpsBase. #UIPATH-ADPV1 Dumps #UIPATH-ADPV1 #UIPATH-ADPV1 Exam Dumps
Post init hook in the odoo 17 ERP ModuleCeline George
In Odoo, hooks are functions that are presented as a string in the __init__ file of a module. They are the functions that can execute before and after the existing code.
Information and Communication Technology in EducationMJDuyan
(𝐓𝐋𝐄 𝟏𝟎𝟎) (𝐋𝐞𝐬𝐬𝐨𝐧 2)-𝐏𝐫𝐞𝐥𝐢𝐦𝐬
𝐄𝐱𝐩𝐥𝐚𝐢𝐧 𝐭𝐡𝐞 𝐈𝐂𝐓 𝐢𝐧 𝐞𝐝𝐮𝐜𝐚𝐭𝐢𝐨𝐧:
Students will be able to explain the role and impact of Information and Communication Technology (ICT) in education. They will understand how ICT tools, such as computers, the internet, and educational software, enhance learning and teaching processes. By exploring various ICT applications, students will recognize how these technologies facilitate access to information, improve communication, support collaboration, and enable personalized learning experiences.
𝐃𝐢𝐬𝐜𝐮𝐬𝐬 𝐭𝐡𝐞 𝐫𝐞𝐥𝐢𝐚𝐛𝐥𝐞 𝐬𝐨𝐮𝐫𝐜𝐞𝐬 𝐨𝐧 𝐭𝐡𝐞 𝐢𝐧𝐭𝐞𝐫𝐧𝐞𝐭:
-Students will be able to discuss what constitutes reliable sources on the internet. They will learn to identify key characteristics of trustworthy information, such as credibility, accuracy, and authority. By examining different types of online sources, students will develop skills to evaluate the reliability of websites and content, ensuring they can distinguish between reputable information and misinformation.
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapitolTechU
Slides from a Capitol Technology University webinar held June 20, 2024. The webinar featured Dr. Donovan Wright, presenting on the Department of Defense Digital Transformation.
Creativity for Innovation and SpeechmakingMattVassar1
Tapping into the creative side of your brain to come up with truly innovative approaches. These strategies are based on original research from Stanford University lecturer Matt Vassar, where he discusses how you can use them to come up with truly innovative solutions, regardless of whether you're using to come up with a creative and memorable angle for a business pitch--or if you're coming up with business or technical innovations.
Brand Guideline of Bashundhara A4 Paper - 2024khabri85
It outlines the basic identity elements such as symbol, logotype, colors, and typefaces. It provides examples of applying the identity to materials like letterhead, business cards, reports, folders, and websites.
How to Create User Notification in Odoo 17Celine George
This slide will represent how to create user notification in Odoo 17. Odoo allows us to create and send custom notifications on some events or actions. We have different types of notification such as sticky notification, rainbow man effect, alert and raise exception warning or validation.
1. NCS-451/JP/ 1
Meerut Institute of Technology, Meerut
Department of Computer Science & Engineering
LAB MANUAL
Lab Name: Operating System
Lab Code: NCS-451
Jyotirmay Patel
2. NCS-451/JP/ 2
Operating System (ECS-551)
List of Experiment
S.No. Program Page No.
1. Testing the Linux /Unix Commands. 5
2. Getting familiar with vi editor and environment. 10
3. Write a C program to simulate FCFS CPU scheduling algorithm. 14
4. Write a C program to simulate SJF CPU scheduling algorithm. 20
5. Write a C program to simulate Priority CPU scheduling algorithm 27
6. Write a C program to simulate Round Robin CPU scheduling
algorithm.
33
7. Write a C program to simulate Banker’s algorithm for deadlock
avoidance.
40
8. Write a C program to simulate FIFO Page replacement algorithm. 50
9. Write a C program to simulate LRU Page replacement algorithm 55
10. Write a C program to simulate FCFS disk scheduling algorithm. 61
11. Write a C program to simulate SSTF disk scheduling algorithm. 66
3. NCS-451/JP/ 3
Hardware/Software Requirements
Hardware:
1. 700 MHz processor (about Intel Celeron or better)
2. 512 MB RAM (system memory)
3. 5 GB of hard-drive space (or USB stick, memory card or external
drive but see LiveCD for an alternative approach)
4. VGA capable of 1024x768 screen resolution
5. Either a CD/DVD drive or a USB port for the installer media
Software:
Ubuntu Desktop OS latest release/ Windows XP/7, Turbo C++ Compiler
Latest Version
4. NCS-451/JP/ 4
Objective of the Lab
1. To familiarize the learners with the Operating System.
2. To introduce LINUX basic commands
3. To get familiarize with vi editor.
4. To make students how to make simple programs in LINUX
5. To implement different CPU scheduling algorithms in C
6. To implement different page replacement algorithms in C
7. To implement Banker algorithms in C
5. NCS-451/JP/ 5
Linux Commands
These commands will work with most (if not all) distributions of Linux as well as most
implementations of UNIX. These are commonly use commands.
Index
1. Navigation - how to get around
o cd - changing directories
o ls - listing files
o pwd - knowing where you are
2. File Management - who needs a graphical file manager?
o cp - copying files
o ln - creating symbolic links
o mv - moving and renaming files
o rm - removing files
3. Monitoring Your System - to satisfy your insatiable curiosity
o tail - follow a file as it grows
o top - a program to see how your memory and CPU are holding up
o w - look at who's logged on
4. Shutting Down and Rebooting - you better know this, though you may not use it a lot
Navigation
Navigating around the files and directories of your hard drive could be a dreaded task for
you, but it is necessary knowledge. If you were a user of command prompt interfaces such as
MS-DOS, you'll have little trouble adjusting. You'll only need to learn a few new commands.
If you're used to navigating using a graphical file manager, I don't know how it'll be like, but
some concepts might require a little more clarification. Or maybe it'll be easier for you. Who
knows? Everyone is different.
cd
As you might already have guessed, the cd command changes directories. It's a very common
navigation command that you'll end up using, just like you might have done in MS-DOS.
You must put a space between cd and the ".." or else it won't work; Linux doesn't see the two
dots as an extension to the cd command, but rather a different command altogether. It'll come
to make sense if it doesn't already.
6. NCS-451/JP/ 6
ls
The ls letters stand for list. It basically works the same way as the dir command in DOS.
Only being a Unix command, you can do more with it. :-)
Typing ls will give you a listing of all the files in the current directory. If you're new to
Linux, chances are that the directories you are commonly in will be empty, and after the ls
command is run, you aren't given any information and will just be returned to the command
prompt (the shell).
There are "hidden" files in Linux, too. Their file names start with a dot, and doing a normal ls
won't show them in a directory. Many configuration files start with a dot on their file names
because they would only get in the way of users who would like to see more commonly used
items. To view hidden files, use the -a flag with the ls command, i.e. ls -a.
To view more information about the files in a directory, use the -l flag with ls. It will show
the file permissions as well as the file size, which are probably what are the most useful
things to know about files.
You might occasionally want to have a listing of all the subdirectories, also. A simple -R flag
will do, so you could look upon ls -R as a rough equivalent of the dir /s command in MS-
DOS.
You can put flags together, so to view all the files in a directory, show their permissions/size,
and view all the files that way through the subdirectories, you could type ls -laR.
pwd
This command simply shows what directory you're in at the moment. It stands for "Print
Working Directory". It's useful for scripting in case you might ever want to refer to your
current directory.
7. NCS-451/JP/ 7
File Management
A lot of people, surprisingly for me, prefer to use graphical file managers. Fortunately for me,
I wasn't spoiled like that and used commands in DOS. That made it a bit easier for me to
make the transition to Linux. Most of the file management Linux gurus do is through the
command line, so if you learn to use the commands, you can brag that you're a guru. Well,
almost.
cp
Copying works very much the same. The cp command can be used just like the MS-DOS
copy command, only remember that directories are separated with slashes (/) instead of
backslashes (). So a basic command line is just cp filename1 filename2.
There are other extensions to the cp command. You can use the -f command to force it. You
can use the -p command to preserve the permissions (and also who owns the file, but I'm not
sure).
You can move an entire directory to its new destination. Let's say you want to copy a
directory (and all of its contents) from where you are to be /home/jack/newdirectory/. You
would type cp -rpf olddirectory /home/jack/newdirectory. To issue this command you
would have to be in the directory where the subdirectory "olddirectory" is actually located.
ln
A feature of linking files is available in Linux. It works by "redirecting" a file to the actual
file. It's referred to as a symbolic link. Don't confuse this term with the linking of programs,
which is when binary programs are connected with libraries that they need to load in order to
run.
The most simple way that I've ever used ln to create symbolic links is ln -s existing_file link.
Evidently there's a hard link and a symbolic link; I've been using a symbolic link all along.
You can also use the -f flag to force the command line to overwrite anything that might have
the symbolic link's file name already.
To remove a symbolic link, simply type rm symbolic_link. It won't remove the file that it's
linked to.
mv
The mv command can be used both to move files and to rename them. The syntax is mv
fileone filetwo, where "fileone" is the original file name and "filetwo" will be the new file
name.
8. NCS-451/JP/ 8
You can't move a directory that is located in one partition to another, unfortunately. You can
copy it, though, using cp -rpf, and then remove it with rm -rf later on. If you have only a
single partition that makes up your filesystem then you have very little to worry about in this
area.
rm
The rm command is used for removing files. You use it just like the del or delete command
in MS-DOS. Let's say you want to remove a file called foobar in your current directory. To
do that, simply type rm foobar. Note that there is no "Recycle Bin" like in Windows 95. So
when you delete a file, it's gone for good.
To delete something in some other directory, use the full path as the file name. For example,
if you want to delete a file called "windows" that's in the directory /usr/local/src/, you would
type rm /usr/local/src/windows.
To remove an entire directory and its contents, type rm -rf /directory where "/directory" is
the path to the directory that you want to delete. If you're wondering, the "rf" stands for
"recursive" and "force". Be very careful with this command, as it can wreak havoc easily if
misused.
Monitoring Your System
An important part of system administration (especially with your own system) is being able
to know what's going on.
tail
The program tail allows you to follow a file as it is growing. Most often, I use it to follow
/var/log/messages. I do that by typing tail -f /var/log/messages. Of course, you can use
anything else, including the other logs in /var/log/. Another file you may want to keep an eye
out for is /var/log/secure.
If you want to leave that running all the time, I recommend having some sort of terminal
program in X, logged in as root through su.
Another program you may want to look at is head. It monitors the top of the file specified,
instead of the bottom.
9. NCS-451/JP/ 9
top
This program shows a lot of stuff that goes on with your system. In the program, you can
type:
1. M for memory usage information
2. P for CPU information
3. q to quit
Once you try it, you can see that top shows you the memory usage, uptime, load average,
CPU states, and processes.
w
Typing w will tell you who is logged in. This can be helpful if you're the only one who uses
your computer and you see someone logged in that's not supposed to be.
Another alternative is who.
Shutting Down and Rebooting
To shut down your system, type shutdown -h now, which tells the shutdown
program to begin system halt immediately. You can also tell it to halt the system at a later
time, I think, but you'll have to consult the shutdown manual page for that (man shutdown).
To do a reboot, you can either type reboot or shutdown -r. You can also use the
famous Ctrl-Alt-Delete combination to reboot, which you might already be familiar with.
Shutting down and restarting properly (as described above) will prevent your
filesystem from being damaged. Filesystem damage is the most obvious of the consequences,
but there are probably other things out there that I don't know about. The point is, shut down
your system properly.
There are (rare!) cases in which the machine might lock up entirely, and prevent you
from being able to access a command prompt. Only then will your last resort be to do a
forced reboot (just pressing the restart button on the case).
10. NCS-451/JP/ 10
vi Editor Commands
General Startup
To use vi: vi filename
To exit vi and save changes: ZZ or :wq
To exit vi without saving changes: :q!
To enter vi command mode: [esc]
Counts
A number preceding any vi command tells vi to
repeat that command that many times.
Cursor Movement
h move left (backspace)
j move down
k move up
l move right (spacebar
[return] move to the beginning of the next line
$ last column on the current line
0 move cursor to the first column on the
current line
^ move cursor to first nonblank column on the
current line
w move to the beginning of the next word or
punctuation mark
W move past the next space
b move to the beginning of the previous word
or punctuation mark
11. NCS-451/JP/ 11
B move to the beginning of the previous word,
ignores punctuation
e end of next word or punctuation mark
E end of next word, ignoring punctuation
H move cursor to the top of the screen
M move cursor to the middle of the screen
L move cursor to the bottom of the screen
Screen Movement
G move to the last line in the file
xG move to line x
z+ move current line to top of screen
z move current line to the middle of screen
z- move current line to the bottom of screen
^F move forward one screen
^B move backward one line
^D move forward one half screen
^U move backward one half screen
^R redraw screen
( does not work with VT100 type terminals )
Inserting
r replace character under cursor with next
character typed
R keep replacing character until [esc] is hit
i insert before cursor
a append after cursor
12. NCS-451/JP/ 12
A append at end of line
O open line above cursor and enter append mode
Deleting
x delete character under cursor
dd delete line under cursor
dw delete word under cursor
db delete word before cursor
Copying Code
yy (yank)'copies' line which may then be put by
the p(put) command. Precede with a count for
multiple lines.
Put Command
brings back previous deletion or yank of lines,
words, or characters
P bring back before cursor
p bring back after cursor
Find Commands
? finds a word going backwards
/ finds a word going forwards
f finds a character on the line under the
cursor going forward
F finds a character on the line under the
cursor going backwards
t find a character on the current line going
forward and stop one character before it
T find a character on the current line going
backward and stop one character before it
; repeat last f, F, t, T
13. NCS-451/JP/ 13
Miscellaneous Commands
. repeat last command
u undoes last command issued
U undoes all commands on one line
xp deletes first character and inserts after
second (swap)
J join current line with the next line
^G display current line number
% if at one parenthesis, will jump to its mate
mx mark current line with character x
'x find line marked with character x
NOTE: Marks are internal and not written to the
file.
Line Editor Mode
Any commands form the line editor ex can be
issued upon entering line mode.
To enter: type ':'
To exit: press[return] or [esc]
14. NCS-451/JP/ 14
PROGRAM 01
STATEMENT OF THE PROBLEM: TO WRITE A C PROGRAM FOR IMPLEMENTING ‘ FIRST
COME FIRST SERVE ’ ALGORITHM.
Concept: Perhaps, First-Come-First-Served algorithm is the simplest scheduling algorithm is the
simplest scheduling algorithm. Processes are dispatched according to their arrival time on the ready
queue. Being a nonpreemptive discipline, once a process has a CPU, it runs to completion. The FCFS
scheduling is fair in the formal sense or human sense of fairness but it is unfair in the sense that long
jobs make short jobs wait and unimportant jobs make important jobs wait.
FCFS is more predictable than most of other schemes since it offers time. FCFS scheme is not
useful in scheduling interactive users because it cannot guarantee good response time. The code for
FCFS scheduling is simple to write and understand. One of the major drawback of this scheme is that
the average time is often quite long.
The First-Come-First-Served algorithm is rarely used as a master scheme in modern
operating systems but it is often embedded within other schemes.
Source code:
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,j,sum=0;
int arrv[10], ser[10], start[10], finish[10],wait[10], turn[10];
float avgturn=0.0,avgwait=0.0;
start[0]=0;
clrscr();
printf("n ENTER THE NO. OF PROCESSES:");
scanf("%d",&n);
15. NCS-451/JP/ 15
for(i=0;i<n;i++)
{
printf("n ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS %d: ",i+1);
scanf("%d%d",&arrv[i],&ser[i]);
}
for(i=0;i<n;i++)
{
sum=0;
for(j=0;j<i;j++)
sum=sum+ser[j];
start[i]=sum;
}
for(i=0;i<n;i++)
{
finish[i]=ser[i]+start[i];
wait[i]=start[i];
turn[i]=ser[i]+wait[i];
}
for(i=0;i<n;i++)
{
avgwait+=wait[i] ;
avgturn+=turn[i];
}
avgwait/=n;
avgturn/=n;
16. NCS-451/JP/ 16
printf("n PROCESS ARRIVAL SERVICE START FINISH WAIT TURN n");
for(i=0;i<n;i++)
{
printf("ntP%dt%d t %d t %d t %d t %d t %d n",i ,arrv[i],
ser[i], start[i], finish[i],wait[i],turn[i]);
}
printf("n AVERAGE WAITING TIME = %f tu",avgwait);
printf("n AVERAGE TURN AROUND TIME = %f tu",
avgturn);
getch();
}
17. NCS-451/JP/ 17
FCFS CPU Scheduling Output:
ENTER THE NO. OF PROCESSES:3
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 1: 0
3
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 2: 1
3
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 3: 2
2
PROCESS ARRIVAL SERVICE START FINISH WAIT TURN
P0 0 3 0 3 0 3
P1 1 3 3 6 3 6
P2 2 2 6 8 6 8
AVERAGE WAITING TIME = 3.000000 tu
AVERAGE TURN AROUND TIME = 5.666667 tu
18. NCS-451/JP/ 18
ENTER THE NO. OF PROCESSES:4
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 1: 1
2
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 2: 3
2
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 3: 1
5
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 4: 4
6
PROCESS ARRIVAL SERVICE START FINISH WAIT TURN
P0 1 2 0 2 0 2
P1 3 2 2 4 2 4
P2 1 5 4 9 4 9
P3 4 6 9 15 9 15
AVERAGE WAITING TIME = 3.750000 tu
AVERAGE TURN AROUND TIME = 7.500000 tu
19. NCS-451/JP/ 19
ENTER THE NO. OF PROCESSES:5
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 1: 1
2
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 2: 3
5
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 3: 2
6
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 4: 3
6
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 5: 5
3
PROCESS ARRIVAL SERVICE START FINISH WAIT TURN
P0 1 2 0 2 0 2
P1 3 5 2 7 2 7
P2 2 6 7 13 7 13
P3 3 6 13 19 13 19
P4 5 3 19 22 19 22
AVERAGE WAITING TIME = 8.200000 tu
AVERAGE TURN AROUND TIME = 12.600000 tu
20. NCS-451/JP/ 20
PROGRAM 02
STATEMENT OF THE PROBLEM: TO WRITE A C PROGRAM FOR IMPLEMENTING ‘
SHORTEST JOB FIRST ’ ALGORITHM.
Concept: Shortest-Job-First (SJF) is a non-preemptive discipline in which waiting job (or process)
with the smallest estimated run-time-to-completion is run next. In other words, when CPU is
available, it is assigned to the process that has smallest next CPU burst. The SJF scheduling is
especially appropriate for batch jobs for which the run times are known in advance. Since the SJF
scheduling algorithm gives the minimum average time for a given set of processes, it is probably
optimal.
The SJF algorithm favors short jobs (or processors) at the expense of longer ones. The obvious
problem with SJF scheme is that it requires precise knowledge of how long a job or process will run,
and this information is not usually available. The best SJF algorithm can do is to rely on user
estimates of run times.
Source code:
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,j,temp1,temp2,sum=0;
int pro[10],arrv[10],ser[10],start[10],finish[10],wait[10],
turn[10];
float avgturn=0.0,avgwait=0.0;
start[0]=0;
clrscr();
21. NCS-451/JP/ 21
printf("n ENTER THE NO. OF PROCESSES:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("n ENTER THE ARRIVAL TIME AND SERVICE TIME
OF PROCESS %d:",i+1);
scanf("%d%d",&arrv[i],&ser[i]);
pro[i]=i;
}
for(i=0;i<n;i++)
{
for(j=0;j<n-i-1;j++)
{
if(ser[j]>ser[j+1])
{
temp1=ser[j];
ser[j]=ser[j+1];
ser[j+1]=temp1;
23. NCS-451/JP/ 23
}
for(i=0;i<n;i++)
{
avgwait +=wait[i] ;
avgturn +=turn[i];
}
avgwait/=n;
avgturn/=n;
printf("n PROCESS ARRIVAL SERVICE START FINISH WAIT
TURN n");
for(i=0;i<n;i++)
{
printf("ntP%dt%d t %d t %d t %d t %d t %d n",
pro[i],arrv[i], ser[i], start[i], finish[i],wait[i],turn[i]);
}
printf("n AVERAGE WAITING TIME = %f tu",avgwait);
printf("n AVERAGE TURN AROUND TIME = %f tu" ,avgturn) ;
getch();
}
24. NCS-451/JP/ 24
SJF CPU Scheduling Output:
ENTER THE NO. OF PROCESSES:3
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 1:5
9
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 2:2
4
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 3:5
6
PROCESS ARRIVAL SERVICE START FINISH WAIT TURN
P0 2 4 0 4 0 4
P1 5 6 4 10 4 10
P2 5 9 10 19 10 19
AVERAGE WAITING TIME = 4.666667 tu
AVERAGE TURN AROUND TIME = 11.000000 tu
25. NCS-451/JP/ 25
ENTER THE NO. OF PROCESSES:4
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 1:2
3
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 2:9
1
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 3:3
3
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 4:5
2
PROCESS ARRIVAL SERVICE START FINISH WAIT TURN
P0 9 1 0 1 0 1
P1 5 2 1 3 1 3
P2 2 3 3 6 3 6
P3 3 3 6 9 6 9
AVERAGE WAITING TIME = 2.500000 tu
AVERAGE TURN AROUND TIME = 4.750000 tu
26. NCS-451/JP/ 26
ENTER THE NO. OF PROCESSES:5
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 1:1
5
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 2:2
3
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 3:4
5
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 4:6
1
ENTER THE ARRIVAL TIME AND SERVICE TIME OF PROCESS 5:5
2
PROCESS ARRIVAL SERVICE START FINISH WAIT TURN
P0 6 1 0 1 0 1
P1 5 2 1 3 1 3
P2 2 3 3 6 3 6
P3 1 5 6 11 6 11
P4 4 5 11 16 11 16
AVERAGE WAITING TIME = 4.200000 tu
AVERAGE TURN AROUND TIME = 7.400000 tu
27. NCS-451/JP/ 27
PROGRAM 03
STATEMENT OF THE PROBLEM: TO WRITE A C PROGRAM FOR IMPLEMENTING
‘ PRIORITY SCHEDULING ’ ALGORITHM.
Concept: Each process is assigned a priority, and priority is allowed to run. Equal-Priority
processes are scheduled in FCFS order. The shortest-Job-First (SJF) algorithm is a special case of
general priority scheduling algorithm.
Source code :
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,j,temp1,temp2,sum=0;
int pro[10],ser[10],start[10],finish[10],wait[10],prior[10], turn[10];
float avgturn=0.0,avgwait=0.0;
start[0]=0;
clrscr();
printf("n ENTER THE NO. OF PROCESSES:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("n ENTER THE SERVICE TIME AND PRIORITY OF PROCESS%d:",i+1);
scanf("%d%d",&ser[i],&prior[i]);
pro[i]=i;
29. NCS-451/JP/ 29
for(i=0;i<n;i++)
{ avgwait+=wait[i] ;
avgturn+=turn[i];
}
avgwait/=n;
avgturn/=n;
printf("n PROCESS SERVICE PRIORITY START FINISH WAIT TURN n");
for(i=0;i<n;i++)
{ printf("ntP%dt%d t %d t %d t %d t %d t %d n", pro[i],ser[i], prior[i],
start[i],finish[i],wait[i],turn[i]);
}
printf("n AVERAGE WAITING TIME = %f tu",avgwait);
printf("n AVERAGE TURN AROUND TIME = %f tu ", avgturn);
getch();
}
30. NCS-451/JP/ 30
Priority CPU Scheduling Output:
ENTER THE NO. OF PROCESSES:3
ENTER THE SERVICE TIME AND PRIORITY OF PROCESS1:4
2
ENTER THE SERVICE TIME AND PRIORITY OF PROCESS2:1
5
ENTER THE SERVICE TIME AND PRIORITY OF PROCESS3:3
4
PROCESS SERVICE PRIORITY START FINISH WAIT TURN
P0 4 2 0 4 0 4
P1 3 4 4 7 4 7
P2 1 5 7 8 7 8
AVERAGE WAITING TIME = 3.666667 tu
AVERAGE TURN AROUND TIME = 6.333333 tu
31. NCS-451/JP/ 31
ENTER THE NO. OF PROCESSES:4
ENTER THE SERVICE TIME AND PRIORITY OF PROCESS1:1
3
ENTER THE SERVICE TIME AND PRIORITY OF PROCESS2:3
5
ENTER THE SERVICE TIME AND PRIORITY OF PROCESS3:2
6
ENTER THE SERVICE TIME AND PRIORITY OF PROCESS4:3
4
PROCESS SERVICE PRIORITY START FINISH WAIT TURN
P0 1 3 0 1 0 1
P1 3 4 1 4 1 4
P2 3 5 4 7 4 7
P3 2 6 7 9 7 9
AVERAGE WAITING TIME = 3.000000 tu
AVERAGE TURN AROUND TIME = 5.250000 tu
32. NCS-451/JP/ 32
ENTER THE NO. OF PROCESSES:5
ENTER THE SERVICE TIME AND PRIORITY OF PROCESS1:4
2
ENTER THE SERVICE TIME AND PRIORITY OF PROCESS2:3
6
ENTER THE SERVICE TIME AND PRIORITY OF PROCESS3:1
6
ENTER THE SERVICE TIME AND PRIORITY OF PROCESS4:2
7
ENTER THE SERVICE TIME AND PRIORITY OF PROCESS5:3
4
PROCESS SERVICE PRIORITY START FINISH WAIT TURN
P0 4 2 0 4 0 4
P1 3 4 4 7 4 7
P2 3 6 7 10 7 10
P3 1 6 10 11 10 11
P4 2 7 11 13 11 13
AVERAGE WAITING TIME = 6.400000 tu
AVERAGE TURN AROUND TIME = 9.000000 tu
33. NCS-451/JP/ 33
PROGRAM 04
STATEMENT OF THE PROBLEM: TO WRITE A C PROGRAM FOR IMPLEMENTING
‘ ROUND ROBIN SCHEDULING ’ ALGORITHM.
Concept: In the round robin scheduling, processes are dispatched in a FIFO manner but are
given a limited amount of CPU time called a time-slice or a quantum. If a process does not complete
before its CPU-time expires, the CPU is preempted and given to the next process waiting in a queue.
The preempted process is then placed at the back of the ready list.
Round Robin Scheduling is preemptive (at the end of time-slice) therefore it is effective in
time-sharing environments in which the system needs to guarantee reasonable response times for
interactive users. The only interesting issue with round robin scheme is the length of the quantum.
Setting the quantum too short causes too many context switches and lower the CPU efficiency. On
the other hand, setting the quantum too long may cause poor response time and appoximates FCFS.
Source code :
#include<stdio.h>
#include<conio.h>
void main()
{
int count=0,swt=0,stat=0,i,temp,sq=0;
int pro[10],st[10],bt[10],wt[10],tat[10],n,tq;
float atat=0.0,awt=0.0;
clrscr();
printf("n ENTER THE NO. OF PROCESSES:");
scanf("%d",&n);
for(i=0;i<n;i++)
34. NCS-451/JP/ 34
{
printf("n ENTER THE SERVICE TIME OF PROCESS %d:",i);
scanf("%d",&bt[i]);
st[i]=bt[i];
pro[i]=i;
}
printf("n ENTER THE TIME QUANTUM:");
scanf("%d",&tq);
while(1)
{
for(i=0,count=0;i<n;i++)
{
temp=tq;
if(st[i]==0)
{
count++;
continue;
}
if(st[i]>tq)
st[i]=st[i]-tq;
36. NCS-451/JP/ 36
printf("n PROCESS BURST TIME WAIT TURN n");
for(i=0;i<n;i++)
{
printf("ntP%dt%d t %d t%dn" ,
pro[i],bt[i],wt[i],tat[i]);
}
printf("n AVERAGE WAITING TIME = %f tu",awt);
printf("n AVERAGE TURN AROUND TIME = %f tu",atat);
getch();
}
37. NCS-451/JP/ 37
Round Robin CPU Scheduling Output:
ENTER THE NO. OF PROCESSES:3
ENTER THE SERVICE TIME OF PROCESS 0:30
ENTER THE SERVICE TIME OF PROCESS 1:40
ENTER THE SERVICE TIME OF PROCESS 2:20
ENTER THE TIME QUANTUM:10
PROCESS BURST TIME WAIT TURN
P0 30 40 70
P1 40 50 90
P2 20 40 60
AVERAGE WAITING TIME = 43.333332 tu
AVERAGE TURN AROUND TIME = 73.333336 tu
38. NCS-451/JP/ 38
ENTER THE NO. OF PROCESSES:4
ENTER THE SERVICE TIME OF PROCESS 0:12
ENTER THE SERVICE TIME OF PROCESS 1:20
ENTER THE SERVICE TIME OF PROCESS 2:9
ENTER THE SERVICE TIME OF PROCESS 3:5
ENTER THE TIME QUANTUM:5
PROCESS BURST TIME WAIT TURN
P0 12 24 36
P1 20 26 46
P2 9 25 34
P3 5 15 20
AVERAGE WAITING TIME = 22.500000 tu
AVERAGE TURN AROUND TIME = 34.000000 tu
39. NCS-451/JP/ 39
ENTER THE NO. OF PROCESSES:5
ENTER THE SERVICE TIME OF PROCESS 0:22
ENTER THE SERVICE TIME OF PROCESS 1:11
ENTER THE SERVICE TIME OF PROCESS 2:34
ENTER THE SERVICE TIME OF PROCESS 3:2
ENTER THE SERVICE TIME OF PROCESS 4:12
ENTER THE TIME QUANTUM:6
PROCESS BURST TIME WAIT TURN
P0 22 43 65
P1 11 26 37
P2 34 47 81
P3 2 18 20
P4 12 37 49
AVERAGE WAITING TIME = 34.200001 tu
AVERAGE TURN AROUND TIME = 50.400002 tu
40. NCS-451/JP/ 40
PROGRAM 05
STATEMENT OF THE PROBLEM: TO WRITE A C PROGRAM FOR IMPLEMENTING
‘BANKERS ALGORITHM‘.
Concept: This approach to the deadlock problem anticipates deadlock before it actually occurs.
This approach employs an algorithm to access the possibility that deadlock could occur and acting
accordingly. This method differs from deadlock prevention, which guarantees that deadlock cannot
occur by denying one of the necessary conditions of deadlock.
If the necessary conditions for a deadlock are in place, it is still possible to avoid deadlock by
being careful when resources are allocated. Perhaps the most famous deadlock avoidance algorithm,
due to Dijkstra, is the Banker’s algorithm. So named because the process is analogous to that used
by a banker in deciding if a loan can be safely made.
The Banker's algorithm considers each request as it occurs, and see if granting it leads to a safe
state. If it does, the request is granted, otherwise, it postponed until later.
SOURCE CODE:
#include<stdio.h>
#include<conio.h>
void main()
{
int clm[7][5],req[7][5],alloc[7][5],rsrc[5],avail[5],comp[7];
int first,p,r,i,j,prc,count,t;
clrscr();
count=0;
for(i=1;i<=7;i++)
41. NCS-451/JP/ 41
comp[i]=0;
printf("Enter the no of processes : ");
scanf("%d",&p);
printf("Enter the no of resource types : ");
scanf("%d",&r);
printf("Enter the claim for each process :n");
for(i=1;i<=p;i++)
{
printf("For process %d : ",i);
for(j=1;j<=r;j++)
{
scanf("%d",&clm[i][j]);
}
}
printf("Enter the allocation for each process :n");
for(i=1;i<=p;i++)
{
printf("For process %d : ",i);
for(j=1;j<=r;j++)
{
42. NCS-451/JP/ 42
scanf("%d",&alloc[i][j]);
}
}
printf("Enter total no of each resource : ");
for(j=1;j<=r;j++)
scanf("%d",&rsrc[j]);
for(j=1;j<=r;j++)
{
int total=0;
avail[j]=0;
for(i=1;i<=p;i++)
{total+=alloc[i][j];}
avail[j]=rsrc[j]-total;
}
do
{
for(i=1;i<=p;i++)
{
for(j=1;j<=r;j++)
{
45. NCS-451/JP/ 45
}
if(prc!=0)
{
printf("nProcess %d runs to completion!",prc);
count++;
for(j=1;j<=r;j++)
{
avail[j]+=alloc[prc][j];
alloc[prc][j]=0;
clm[prc][j]=0;
comp[prc]=1;
}
}
}while(count!=p+1 && prc!=0);
if(count==p)
printf("nThe system is in a safe state!!");
else
printf("nThe system is in an unsafe state!!");
getch();
}
46. NCS-451/JP/ 46
Banker Algorithm Output
Enter the no of processes : 3
Enter the no of resource types : 4
Enter the claim for each process :
For process 1 : 2
1
3
4
For process 2 : 5
6
7
2
For process 3 : 3
4
5
6
Enter the allocation for each process :
For process 1 : 2
3
4
5
For process 2 : 6
1
2
3
For process 3 : 4
47. NCS-451/JP/ 47
2
3
4
Enter total no of each resource : 1
8
9
4
Claim matrix: Allocation matrix: Request matrix:
2 1 3 4 2 3 4 5 0-2-1-1
5 6 7 2 6 1 2 3 -1 5 5-1
3 4 5 6 4 2 3 4 -1 2 2 2
Available resources are : -11 2 0 -8
The system is in an unsafe state!!
48. NCS-451/JP/ 48
Enter the no of processes : 3
Enter the no of resource types : 2
Enter the claim for each process :
For process 1 : 2
3
For process 2 : 1
2
For process 3 : 2
3
Enter the allocation for each process :
For process 1 : 1
1
For process 2 : 1
1
For process 3 : 0
1
Enter total no of each resource : 6
7
Claim matrix: Allocation matrix: Request matrix:
2 3 1 1 1 2
1 2 1 1 0 1
2 3 0 1 2 2
Available resources are : 4 4
Process 1 runs to completion!
Claim matrix: Allocation matrix: Request matrix:
49. NCS-451/JP/ 49
0 0 0 0 0 0
1 2 1 1 0 1
2 3 0 1 2 2
Available resources are : 5 5
Process 2 runs to completion!
Claim matrix: Allocation matrix: Request matrix:
0 0 0 0 0 0
0 0 0 0 0 0
2 3 0 1 2 2
Available resources are : 6 6
Process 3 runs to completion!
Claim matrix: Allocation matrix: Request matrix:
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
Available resources are : 6 7
The system is in a safe state!!
50. NCS-451/JP/ 50
PROGRAM 06
STATEMENT OF THE PROBLEM: TO WRITE A C PROGRAM FOR IMPLEMENTING
‘ FIRST IN FIRST OUT PAGE REPLACEMENT ’ ALGORITHM.
Concept: The simplest page-replacement algorithm is a FIFO algorithm. The first-in, first-out
(FIFO) page replacement algorithm is a low-overhead algorithm that requires little book-keeping on
the part of the operating system. The idea is obvious from the name – the operating system keeps
track of all the pages in memory in a queue, with the most recent arrival at the back, and the oldest
arrival in front. When a page needs to be replaced, the page at the front of the queue (the oldest
page) is selected. While FIFO is cheap and intuitive, it performs poorly in practical application. Thus,
it is rarely used in its unmodified form.
Source code:
#include<conio.h>
#include<stdio.h>
void main()
{ int i,j,n,a[50],frame[10],no,k,avail,count=0;
clrscr();
printf("n ENTER THE NO. OF PAGES: ");
scanf("%d",&n);
printf("n ENTER THE PAGE Reference String.: ");
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
printf("n ENTER THE NO. OF FRAMES: ");
scanf("%d",&no);
for(i=0;i<no;i++)
frame[i]=-1;
52. NCS-451/JP/ 52
FIFO Page Replacement Algorithm Output
ENTER THE NO. OF PAGES: 5
ENTER THE PAGE Reference String.: 1
2
3
4
2
ENTER THE NO. OF FRAMES: 3
REF. STRING PAGE FRAMES
1 1 -1 -1
2 1 2 -1
3 1 2 3
4 4 2 3
2
NO. OF PAGE FAULTS : 4
53. NCS-451/JP/ 53
ENTER THE NO. OF PAGES: 7
ENTER THE PAGE Reference String.: 1
2
3
1
2
3
4
ENTER THE NO. OF FRAMES: 3
REF. STRING PAGE FRAMES
1 1 -1 -1
2 1 2 -1
3 1 2 3
1
2
3
4 4 2 3
NO. OF PAGE FAULTS : 4
54. NCS-451/JP/ 54
ENTER THE NO. OF PAGES: 6
ENTER THE PAGE Reference String.: 2
2
2
2
2
2
ENTER THE NO. OF FRAMES: 3
REF. STRING PAGE FRAMES
2 2 -1 -1
2
2
2
2
2
NO. OF PAGE FAULTS: 1
55. NCS-451/JP/ 55
PROGRAM 07
STATEMENT OF THE PROBLEM: TO WRITE A C PROGRAM FOR IMPLEMENTING
‘ LEAST RECENTLY USED PAGE REPLACEMENT ’ ALGORITHM.
Concept: The Least Recently Used replacement policy chooses to replace the page which has not
been referenced for the longest time. This policy assumes the recent past will approximate the
immediate future. The operating system keeps track of when each page was referenced by recording
the time of reference or by maintaining a stack of references.
Source code :
#include<stdio.h>
void main()
{
int q[20],p[50],c=0,c1,d,f,i,j,k=0,n,r,t,b[20],c2[20];
printf("Enter no of pages:");
scanf("%d",&n);
printf("Enter the reference string:");
for(i=0;i<n;i++)
scanf("%d",&p[i]);
printf("Enter no of frames:");
scanf("%d",&f);
q[k]=p[k];
printf("nt%dn",q[k]);
c++;
k++;
for(i=1;i<n;i++)
{
58. NCS-451/JP/ 58
LRU Page Replacement Algorithm Output
Enter no of pages:4
Enter the reference string:2
3
1
2
Enter no of frames:2
2
2 3
1 3
1 2
The no of page faults is : 4
59. NCS-451/JP/ 59
Enter no of pages:7
Enter the reference string:1
2
3
2
4
2
5
Enter no of frames:3
1
1 3
1 3 2
4 3 2
4 5 2
The no of page faults is : 5
60. NCS-451/JP/ 60
Enter no of pages:8
Enter the reference string:1
2
1
2
3
1
2
3
Enter no of frames:2
1
1 2
3 2
3 1
2 1
2 3
The no of page faults is : 6
61. NCS-451/JP/ 61
PROGRAM 8
STATEMENT OF THE PROBLEM: TO WRITE A C PROGRAM FOR
IMPLEMENTINGFIFO(FIRST IN FIRST OUT) DISK SCHEDULING.
Concept: All incoming requests are placed at the end of the queue. Whatever number that is
next in the queue will be the next number served. This algorithm doesn't provide the best results. To
determine the number of head movements we would simply find the number of tracks it took to
move from one request to the next.
SOURCE CODE:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
int a[20],n,i,t=0;
clrscr();
printf("Enter head pointer position:");
scanf("%d",&a[0]);
printf("nEnter number of disk request:");
scanf("%d",&n);
printf("nEnter request in order");
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
if(a[i]<0)
63. NCS-451/JP/ 63
FCFS Disk Scheduling Algorithm Output:
Enter head pointer position:500
Enter number of disk request:4
Enter request in order100
200
400
300
Processing order: 500 100 200 400 300
Total Head Movement:800
64. NCS-451/JP/ 64
Enter head pointer position:200
Enter number of disk request:6
Enter request in order300
100
400
200
250
550
Processing order: 200 300 100 400 200 250 550
Total Head Movement:1150
65. NCS-451/JP/ 65
Enter head pointer position:200
Enter number of disk request:4
Enter request in order200
100
-300
INVALID INPUT
66. NCS-451/JP/ 66
PROGRAM 9
STATEMENT OF THE PROBLEM: TO WRITE A C PROGRAM FOR IMPLEMENTING
SSTF(SHORTEST SEEK TIME FIRST) DISK SCHEDULING.
Concept: In this case request is serviced according to next shortest distance
from the header position.
SOURCE CODE:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>0
void main()
{
int a[20],b[20],d,n,i,j,temp,s,k=0,x=0,t=0;
clrscr();
printf("Enter head pointer position:");
scanf("%d",&a[0]);
printf("nEnter number of processes:");
scanf("%d",&n);
printf("nEnter processes in request order");
for(i=1;i<=n;i++)
{
69. NCS-451/JP/ 69
SSTF Disk Scheduling Algorithm Output
Enter head pointer position:100
Enter number of processes:4
Enter processes in request order200
100
500
200
Processing order: 100 100 200 200 500
Total Head Movement:400
70. NCS-451/JP/ 70
Enter head pointer position:500
Enter number of processes:6
Enter processes in request order400
300
200
600
700
600
Processing order: 500 400 300 200 600 600 700
Total Head Movement:800
71. NCS-451/JP/ 71
Enter head pointer position:700
Enter number of processes:7
Enter processes in request order500
600
300
-700
INVALID INPUT