The document describes the lab manual for the Operating Systems course, including the list of 12 experiments covering topics like CPU scheduling algorithms, file allocation strategies, semaphores, deadlock detection/prevention, page replacement algorithms, and threading. The manual provides an index with spaces to record the date, name of experiment, signature of the staff member, and any remarks for each of the 15 experiments to be completed.
The document provides an overview of operating system concepts including its roles, configuration, functions and key components like job management and process management. It discusses how the operating system efficiently manages computer resources through functions like job scheduling, multi-programming and I/O management. It also describes the different types of interrupts and how the kernel controls process execution through interrupt handling.
A binary semaphore is a synchronization primitive that can have the values of 0 or 1. They are used to implement mutual exclusion and synchronize concurrent processes. Paging is when pages of memory are written to disk to make space in physical memory for other processes, which can lead to thrashing if too many page faults occur from too much paging. The four conditions that can lead to a deadlock are mutual exclusion, hold and wait, no preemption, and circular wait.
The document provides an overview of basic computer operating systems concepts. It discusses file management, file systems, directories, paths, file operations, and roles in file management. It also summarizes concepts related to security management, failure management, supervisors, and where to find more information on operating systems.
Introduction to Operating System (Important Notes)Gaurav Kakade
The document provides definitions and explanations of various operating system concepts. It discusses context switching, rollbacks, system calls, the definition of an operating system, swapping, semaphores, Belady's anomaly, waiting time, claim edges in resource allocation graphs, whether round robin is preemptive, the definition of an editor, fragmentation, files and their attributes, page faults, turnaround time, multiprogramming, overlays in memory management, processes, compile time, deadlocks, basic file operations, dispatchers, classic synchronization problems, and pages and frames in memory management. It also explains deadlock prevention strategies such as mutual exclusion, hold and wait, and no preemption.
This chapter introduces operating systems and their major components. It discusses how operating systems act as an intermediary between the user and computer hardware to execute programs and manage system resources like the CPU, memory, storage and I/O devices. It also covers the basic structure of a computer system including hardware components, the operating system, application programs, and users. Key operating system functions like process management, memory management and storage management are introduced.
This document provides course material for the subject of Operating Systems for 4th semester B.E. Computer Science Engineering students at A.V.C. College of Engineering. It includes information on the name and designation of the faculty teaching the course, the academic year, curriculum regulations, 5 units that make up the course content, textbook and reference details. The course aims to cover key topics in operating systems including processes, process scheduling, storage management, file systems and I/O systems.
The document discusses operating systems and processes. It defines an operating system as an interface between the user and computer hardware that manages system resources efficiently. Processes are programs in execution that are represented in memory by a process control block containing information like state, registers, scheduling details. Processes go through various states like running, ready, waiting and terminated. The document also describes process creation, termination, and context switching between processes.
The document discusses operating system interview questions and answers. It covers topics such as the definition of an operating system, basic functions of an OS, types of operating systems, kernel functions, process states, virtual memory, deadlocks, threads, synchronization, scheduling algorithms, and memory management. Some key points covered are that an OS acts as an intermediary between the user and hardware, the kernel provides basic services, processes can be in states like running, waiting, or ready, and virtual memory uses timesharing to simulate more memory than physically available.
The document provides an overview of operating system concepts including its roles, configuration, functions and key components like job management and process management. It discusses how the operating system efficiently manages computer resources through functions like job scheduling, multi-programming and I/O management. It also describes the different types of interrupts and how the kernel controls process execution through interrupt handling.
A binary semaphore is a synchronization primitive that can have the values of 0 or 1. They are used to implement mutual exclusion and synchronize concurrent processes. Paging is when pages of memory are written to disk to make space in physical memory for other processes, which can lead to thrashing if too many page faults occur from too much paging. The four conditions that can lead to a deadlock are mutual exclusion, hold and wait, no preemption, and circular wait.
The document provides an overview of basic computer operating systems concepts. It discusses file management, file systems, directories, paths, file operations, and roles in file management. It also summarizes concepts related to security management, failure management, supervisors, and where to find more information on operating systems.
Introduction to Operating System (Important Notes)Gaurav Kakade
The document provides definitions and explanations of various operating system concepts. It discusses context switching, rollbacks, system calls, the definition of an operating system, swapping, semaphores, Belady's anomaly, waiting time, claim edges in resource allocation graphs, whether round robin is preemptive, the definition of an editor, fragmentation, files and their attributes, page faults, turnaround time, multiprogramming, overlays in memory management, processes, compile time, deadlocks, basic file operations, dispatchers, classic synchronization problems, and pages and frames in memory management. It also explains deadlock prevention strategies such as mutual exclusion, hold and wait, and no preemption.
This chapter introduces operating systems and their major components. It discusses how operating systems act as an intermediary between the user and computer hardware to execute programs and manage system resources like the CPU, memory, storage and I/O devices. It also covers the basic structure of a computer system including hardware components, the operating system, application programs, and users. Key operating system functions like process management, memory management and storage management are introduced.
This document provides course material for the subject of Operating Systems for 4th semester B.E. Computer Science Engineering students at A.V.C. College of Engineering. It includes information on the name and designation of the faculty teaching the course, the academic year, curriculum regulations, 5 units that make up the course content, textbook and reference details. The course aims to cover key topics in operating systems including processes, process scheduling, storage management, file systems and I/O systems.
The document discusses operating systems and processes. It defines an operating system as an interface between the user and computer hardware that manages system resources efficiently. Processes are programs in execution that are represented in memory by a process control block containing information like state, registers, scheduling details. Processes go through various states like running, ready, waiting and terminated. The document also describes process creation, termination, and context switching between processes.
The document discusses operating system interview questions and answers. It covers topics such as the definition of an operating system, basic functions of an OS, types of operating systems, kernel functions, process states, virtual memory, deadlocks, threads, synchronization, scheduling algorithms, and memory management. Some key points covered are that an OS acts as an intermediary between the user and hardware, the kernel provides basic services, processes can be in states like running, waiting, or ready, and virtual memory uses timesharing to simulate more memory than physically available.
The document discusses operating systems and computer system architecture. It defines an operating system as a program that manages a computer's hardware resources and provides common services for application software. It describes the components of a computer system as the CPU, memory, I/O devices, and how the operating system controls and coordinates their use. It also discusses different types of operating systems designed for single-user systems, multi-user systems, servers, handheld devices, and embedded systems.
The document discusses processes and process management in operating systems. It defines a process as the unit of execution, scheduling, and ownership. A process consists of code, data, a stack, registers, and other components needed to run a program. Processes can be in different states like ready, running, waiting. The OS uses data structures called process control blocks (PCBs) to manage process states and execution contexts. It also maintains scheduling queues to organize processes in different states. Process creation, termination, and interprocess communication (IPC) allow processes to work together in a system.
Bba203 unit 2 operating system conceptskinjal patel
The document provides an introduction to operating systems, outlining their key functions and types. It discusses single-user and multi-user operating systems, how operating systems manage resources and devices, and important concepts like booting, file management, and multitasking. Specific examples of operating systems are given for each type, like DOS, Windows, and Linux. The document also defines important terms related to operating systems such as files, directories, volume labels, and different types of file access.
This document contains two sample question papers for an Operating Systems exam for a 4th semester BTech course in IT/CSE. Each paper has three sections - Section A contains 10 short answer questions worth 2 marks each, Section B contains 4 long answer questions worth 5 marks each, and Section C contains 2 long answer questions worth 10 marks each. The questions cover topics like virtual memory, processes, threads, CPU scheduling algorithms, deadlocks, memory management techniques like paging, segmentation, swapping etc.
This document provides an overview of processes in operating systems. It defines a process as a program in execution and notes that a process includes the program counter, stack, data section, and other resources. It describes the different states a process can be in like new, ready, running, blocked, and terminated. Process scheduling and context switching are also summarized. The document outlines techniques for process creation and termination. It discusses interprocess communication methods like shared memory and message passing. In summary, the document defines processes and key concepts regarding their management in an operating system.
The document discusses operating systems and some of their core concepts. It defines an operating system as a program that manages computer hardware and acts as an intermediary between users and the computer. It then discusses key OS components like process management, memory management, and protection systems. It also covers concepts like multiprocessing, threads, process states, and context switching.
This document contains a question bank on various topics in operating systems including:
1. Process synchronization questions focusing on critical section problems, semaphores, and solutions for two processes.
2. Memory management questions on paging and segmentation.
3. Deadlock questions on safe/unsafe states, bankers algorithm, prevention/avoidance strategies, and recovery from deadlocks.
4. CPU scheduling questions on algorithms like FCFS, RR, SJF and characteristics like short term, long term and medium term schedulers.
5. Process management questions on states, control blocks, creation/termination, and interprocess communication.
The questions provided are meant to help students study notes
FellowBuddy.com is an innovative platform that brings students together to share notes, exam papers, study guides, project reports and presentation for upcoming exams.
We connect Students who have an understanding of course material with Students who need help.
Benefits:-
# Students can catch up on notes they missed because of an absence.
# Underachievers can find peer developed notes that break down lecture and study material in a way that they can understand
# Students can earn better grades, save time and study effectively
Our Vision & Mission – Simplifying Students Life
Our Belief – “The great breakthrough in your life comes when you realize it, that you can learn anything you need to learn; to accomplish any goal that you have set for yourself. This means there are no limits on what you can be, have or do.”
Like Us - https://www.facebook.com/FellowBuddycom
The document provides an overview of operating systems, including what constitutes an OS (kernel, system programs, application programs), storage device hierarchy, system calls, process creation and states, process scheduling, inter-process communication methods like shared memory and pipes, synchronization techniques like mutexes and semaphores, readers-writers problem, and potential for deadlocks. Key concepts covered include kernel mode vs user mode, process control blocks, context switching, preemption, and requirements for deadlock situations.
The document discusses the concept of processes in operating systems. It defines a process as a program in execution that must progress sequentially. A process includes the executing program, its current state, and associated system resources. All runnable software is organized into processes that the CPU rapidly switches between, allowing them to run pseudo-parallel. The OS maintains processes through their creation, execution, and termination. It uses process control blocks (PCBs) that contain information about each process to implement the process model.
Linux Memory Management
1.Memory Structure of Linux OS.
2.How Program is loaded into the memory.
3.Address Translation.
4.Feature for Multithreading and Multiprocessing.
The document discusses the architecture and internals of Unix operating systems. It describes the high-level architecture with the hardware at the bottom providing basic services, the operating system kernel interacting directly with hardware and providing common services to user programs, and user programs being isolated from hardware. It also discusses topics like multiprocessing, multi-core processors, operating system services like process management and scheduling, and the file subsystem as a key part of the Unix kernel architecture.
The document provides an overview of operating systems, including processes, threads, interprocess communication, deadlocks, and scheduling. It discusses the evolution of operating systems from first to fourth generation. Key concepts covered include processes, files, system calls, command interpreters, and signals. Operating system structures like monolithic, layered, and client-server models are summarized. Common interprocess communication problems like the bounded buffer, readers-writers, and dining philosophers problems are also briefly outlined. Finally, it discusses process scheduling algorithms, deadlock conditions and strategies to handle deadlocks.
In the given presentation, process overview,process management scheduling typesand some more basic concepts were explained.
Kindly refere the presentation.
This document provides an introduction to basic operating system concepts. It defines what an operating system is and discusses its main goals of executing user programs, making the computer convenient to use, and efficiently utilizing computer hardware. It then describes different types of systems that operating systems support, including mainframe, desktop, multiprocessor, distributed, clustered, and real-time systems. The key aspects and features required of operating systems to support these different system types are also outlined.
The document provides an introduction to operating systems. It defines an operating system as a program that acts as an intermediary between the user and computer hardware. The goals of an operating system are to execute user programs, make the computer system convenient to use, and efficiently use computer hardware resources. A computer system consists of hardware, an operating system, application programs, and users. The operating system controls and coordinates the use of hardware resources among applications and users.
This presentation discusses system calls and provides an overview of their key aspects:
System calls provide an interface between processes and the operating system. They allow programs to request services from the OS like reading/writing files. There are different methods of passing parameters to the OS, such as via registers, parameter blocks, or pushing to the stack. System calls fall into categories including process control, file management, device management, information maintenance, and communication. An example is given of how system calls would be used in a program to copy data between two files.
Gives an overview about Process, PCB, Process States, Process Operations, Scheduling, Schedulers, Interprocess communication, shared memory and message passing systems
SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...vtunotesbysree
Here are three major complications that concurrent processing adds to an operating system:
1. Resource allocation and scheduling becomes more complex. The OS must allocate CPU time, memory, file descriptors, etc. among multiple concurrent processes and ensure all processes receive adequate resources. It must also schedule which process runs at what time on what CPU core.
2. Synchronization and communication between processes is more difficult. The OS must provide mechanisms for processes to synchronize their actions when accessing shared resources and to allow inter-process communication. This introduces challenges around things like race conditions and deadlocks.
3. Reliability and fault tolerance is harder. If one process crashes or hangs, it should not affect other processes. The OS must be able to
LM1 - Computer System Overview, system callsmanideepakc
The document discusses operating system concepts including:
1. It provides an overview of computer system elements like the CPU, memory, I/O devices and how the operating system acts as an intermediary between the user and hardware.
2. It describes instruction execution involving fetching, decoding and executing instructions in memory.
3. It explains interrupts as signals that alert the processor to high priority processes, and how the operating system handles interrupts through interrupt service routines.
The document discusses operating systems and their core functions. It covers:
1) Operating systems control computers by managing processes, memory, networking, protection, and scheduling.
2) Operating systems aim to allocate resources to processes, manage main memory, and protect systems from unauthorized access.
3) Key components of operating systems include processes, threads, scheduling algorithms, system calls, interprocess communication using semaphores, and memory management.
The document discusses operating systems and computer system architecture. It defines an operating system as a program that manages a computer's hardware resources and provides common services for application software. It describes the components of a computer system as the CPU, memory, I/O devices, and how the operating system controls and coordinates their use. It also discusses different types of operating systems designed for single-user systems, multi-user systems, servers, handheld devices, and embedded systems.
The document discusses processes and process management in operating systems. It defines a process as the unit of execution, scheduling, and ownership. A process consists of code, data, a stack, registers, and other components needed to run a program. Processes can be in different states like ready, running, waiting. The OS uses data structures called process control blocks (PCBs) to manage process states and execution contexts. It also maintains scheduling queues to organize processes in different states. Process creation, termination, and interprocess communication (IPC) allow processes to work together in a system.
Bba203 unit 2 operating system conceptskinjal patel
The document provides an introduction to operating systems, outlining their key functions and types. It discusses single-user and multi-user operating systems, how operating systems manage resources and devices, and important concepts like booting, file management, and multitasking. Specific examples of operating systems are given for each type, like DOS, Windows, and Linux. The document also defines important terms related to operating systems such as files, directories, volume labels, and different types of file access.
This document contains two sample question papers for an Operating Systems exam for a 4th semester BTech course in IT/CSE. Each paper has three sections - Section A contains 10 short answer questions worth 2 marks each, Section B contains 4 long answer questions worth 5 marks each, and Section C contains 2 long answer questions worth 10 marks each. The questions cover topics like virtual memory, processes, threads, CPU scheduling algorithms, deadlocks, memory management techniques like paging, segmentation, swapping etc.
This document provides an overview of processes in operating systems. It defines a process as a program in execution and notes that a process includes the program counter, stack, data section, and other resources. It describes the different states a process can be in like new, ready, running, blocked, and terminated. Process scheduling and context switching are also summarized. The document outlines techniques for process creation and termination. It discusses interprocess communication methods like shared memory and message passing. In summary, the document defines processes and key concepts regarding their management in an operating system.
The document discusses operating systems and some of their core concepts. It defines an operating system as a program that manages computer hardware and acts as an intermediary between users and the computer. It then discusses key OS components like process management, memory management, and protection systems. It also covers concepts like multiprocessing, threads, process states, and context switching.
This document contains a question bank on various topics in operating systems including:
1. Process synchronization questions focusing on critical section problems, semaphores, and solutions for two processes.
2. Memory management questions on paging and segmentation.
3. Deadlock questions on safe/unsafe states, bankers algorithm, prevention/avoidance strategies, and recovery from deadlocks.
4. CPU scheduling questions on algorithms like FCFS, RR, SJF and characteristics like short term, long term and medium term schedulers.
5. Process management questions on states, control blocks, creation/termination, and interprocess communication.
The questions provided are meant to help students study notes
FellowBuddy.com is an innovative platform that brings students together to share notes, exam papers, study guides, project reports and presentation for upcoming exams.
We connect Students who have an understanding of course material with Students who need help.
Benefits:-
# Students can catch up on notes they missed because of an absence.
# Underachievers can find peer developed notes that break down lecture and study material in a way that they can understand
# Students can earn better grades, save time and study effectively
Our Vision & Mission – Simplifying Students Life
Our Belief – “The great breakthrough in your life comes when you realize it, that you can learn anything you need to learn; to accomplish any goal that you have set for yourself. This means there are no limits on what you can be, have or do.”
Like Us - https://www.facebook.com/FellowBuddycom
The document provides an overview of operating systems, including what constitutes an OS (kernel, system programs, application programs), storage device hierarchy, system calls, process creation and states, process scheduling, inter-process communication methods like shared memory and pipes, synchronization techniques like mutexes and semaphores, readers-writers problem, and potential for deadlocks. Key concepts covered include kernel mode vs user mode, process control blocks, context switching, preemption, and requirements for deadlock situations.
The document discusses the concept of processes in operating systems. It defines a process as a program in execution that must progress sequentially. A process includes the executing program, its current state, and associated system resources. All runnable software is organized into processes that the CPU rapidly switches between, allowing them to run pseudo-parallel. The OS maintains processes through their creation, execution, and termination. It uses process control blocks (PCBs) that contain information about each process to implement the process model.
Linux Memory Management
1.Memory Structure of Linux OS.
2.How Program is loaded into the memory.
3.Address Translation.
4.Feature for Multithreading and Multiprocessing.
The document discusses the architecture and internals of Unix operating systems. It describes the high-level architecture with the hardware at the bottom providing basic services, the operating system kernel interacting directly with hardware and providing common services to user programs, and user programs being isolated from hardware. It also discusses topics like multiprocessing, multi-core processors, operating system services like process management and scheduling, and the file subsystem as a key part of the Unix kernel architecture.
The document provides an overview of operating systems, including processes, threads, interprocess communication, deadlocks, and scheduling. It discusses the evolution of operating systems from first to fourth generation. Key concepts covered include processes, files, system calls, command interpreters, and signals. Operating system structures like monolithic, layered, and client-server models are summarized. Common interprocess communication problems like the bounded buffer, readers-writers, and dining philosophers problems are also briefly outlined. Finally, it discusses process scheduling algorithms, deadlock conditions and strategies to handle deadlocks.
In the given presentation, process overview,process management scheduling typesand some more basic concepts were explained.
Kindly refere the presentation.
This document provides an introduction to basic operating system concepts. It defines what an operating system is and discusses its main goals of executing user programs, making the computer convenient to use, and efficiently utilizing computer hardware. It then describes different types of systems that operating systems support, including mainframe, desktop, multiprocessor, distributed, clustered, and real-time systems. The key aspects and features required of operating systems to support these different system types are also outlined.
The document provides an introduction to operating systems. It defines an operating system as a program that acts as an intermediary between the user and computer hardware. The goals of an operating system are to execute user programs, make the computer system convenient to use, and efficiently use computer hardware resources. A computer system consists of hardware, an operating system, application programs, and users. The operating system controls and coordinates the use of hardware resources among applications and users.
This presentation discusses system calls and provides an overview of their key aspects:
System calls provide an interface between processes and the operating system. They allow programs to request services from the OS like reading/writing files. There are different methods of passing parameters to the OS, such as via registers, parameter blocks, or pushing to the stack. System calls fall into categories including process control, file management, device management, information maintenance, and communication. An example is given of how system calls would be used in a program to copy data between two files.
Gives an overview about Process, PCB, Process States, Process Operations, Scheduling, Schedulers, Interprocess communication, shared memory and message passing systems
SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...vtunotesbysree
Here are three major complications that concurrent processing adds to an operating system:
1. Resource allocation and scheduling becomes more complex. The OS must allocate CPU time, memory, file descriptors, etc. among multiple concurrent processes and ensure all processes receive adequate resources. It must also schedule which process runs at what time on what CPU core.
2. Synchronization and communication between processes is more difficult. The OS must provide mechanisms for processes to synchronize their actions when accessing shared resources and to allow inter-process communication. This introduces challenges around things like race conditions and deadlocks.
3. Reliability and fault tolerance is harder. If one process crashes or hangs, it should not affect other processes. The OS must be able to
LM1 - Computer System Overview, system callsmanideepakc
The document discusses operating system concepts including:
1. It provides an overview of computer system elements like the CPU, memory, I/O devices and how the operating system acts as an intermediary between the user and hardware.
2. It describes instruction execution involving fetching, decoding and executing instructions in memory.
3. It explains interrupts as signals that alert the processor to high priority processes, and how the operating system handles interrupts through interrupt service routines.
The document discusses operating systems and their core functions. It covers:
1) Operating systems control computers by managing processes, memory, networking, protection, and scheduling.
2) Operating systems aim to allocate resources to processes, manage main memory, and protect systems from unauthorized access.
3) Key components of operating systems include processes, threads, scheduling algorithms, system calls, interprocess communication using semaphores, and memory management.
The document discusses operating systems, including what they are, their structure and functions. It defines an operating system as software that enables computer programs to run by managing hardware resources. The key points covered are:
- Operating systems control and allocate memory, prioritize tasks, manage files and I/O devices.
- They consist of four layers - hardware, OS software, system programs and application programs.
- Types of OS include batch, multiprogramming, time-sharing, multi-user and real-time systems.
- Their main components are process management, memory management, file management and I/O management.
- OS provide services like resource allocation, protection and user interfaces to facilitate programming.
This document discusses types of operating systems and utilization of CPUs. It begins by defining operating systems and providing examples. It then describes various types of operating systems including single-tasking vs multi-tasking, single-user vs multi-user, distributed, templated, embedded, real-time, and library operating systems. It also discusses CPU scheduling and how it allows processes to share CPU resources. It defines CPU utilization and provides formulas to calculate it. Finally, it lists some scheduling criteria like CPU utilization, throughput, turnaround time, waiting time, and response time that help improve CPU usage.
This document provides an introduction and overview of operating systems. It begins with definitions of operating systems and their role in managing computer hardware resources and acting as an interface between users and computers. Some key functions of operating systems are then summarized, including memory management, processor management, device management, file management, and security. Popular operating system types are also briefly outlined, such as batch operating systems, multi-programming systems, time-sharing systems, distributed systems, and real-time systems.
This document provides an overview of operating system concepts including system components, operating system services, system programs, system calls, process management, and process states. It describes the four main components of a computer system as hardware, operating system, application programs, and users. It defines key operating system concepts such as multiprogramming, time-sharing, distributed systems, and real-time systems. It also explains process management topics like process states, process control blocks, and context switching.
Unit I (8 Hrs)
Introduction to System Software , Overview of all system software’s: Operating system
I/O manager, Assembler, Compiler, Linker ,Loader.
Introductory Concepts: Operating system functions and characteristics, historical evolution
of operating systems, Real time systems, Distributed systems.
Unit II (8 Hrs)
Operating Systems: Methodologies for implementation of O/S service system calls,
system programs, Interrupt mechanisms.
Process - Concept of process and threads, Process states, Process management, Context
switching
Interaction between processes and OS Multithreading Process Control, Job schedulers,
Job Scheduling, scheduling criteria, scheduling algorithms
Unit III (8 Hrs)
Concurrency Control : Concurrency and Race Conditions, Mutual exclusion requirements
Software and hardware solutions, Semaphores, Monitors, Classical IPC problems and
solutions.
Deadlock : Characterization, Detection, Recovery, Avoidance and Prevention.
Unit IV (8 Hrs)
Memory management: Contiguous and non-contiguous, Swapping, Paging, Segmentation
and demand Paging, Virtual Memory, Management of Virtual memory: allocation, fetch and
replacement
Unit V (8 Hrs)
File Management: Concept, Access methods, Directory Structure, Protection, File System
implementation, Directory Implementation, Allocation methods, Free Space management,
efficiency and performance
IO systems: disk structure, disk scheduling, disk management.
Unit VI (8 Hrs)
Case Study of Linux: Structure of LINUX, design principles, kernel, process management and
scheduling, file systems installing requirement, basic architecture of UNIX/Linux system, Kernel,
Shell Commands for files and directories cd, cp, mv, rm, mkdir, more, less, creating and viewing
files, using cat, file comparisons, View files, disk related commands, checking disk free spaces,
Essential linux commands.
Understanding shells, Processes in linux – process fundamentals, connecting processes with pipes,
Redirecting input output, manual help, Background processing, managing multiple processes,
changing process priority, scheduling of processes at command, batch commands, kill, ps, who,
sleep, Printing commands, grep, fgrep, find, sort, cal, banner, touch, file, file related commands – ws,sat, cut, grep, dd, etc. Mathematical commands – bc, expr, factor, units. Vi, joe, vim editor
This document provides an overview of operating system concepts including system components, batch systems, spooling, multiprogramming, time-sharing systems, distributed systems, parallel systems, real-time embedded systems, system structures, system calls, system programs, and process management. It describes the basic functions of an operating system in managing hardware resources, running application programs, and allowing multiple processes to run concurrently through techniques like multiprocessing and time-sharing.
Theory related to OS :
It Includes:
1. Unit I (COMPONENTS OF COMPUTER SYSTEM)
2. Unit II (OPERATING SYSTEM STRUCTURE)
3. Unit III (PROCESS MANAGEMENT)
4. Unit IV (MEMORY MANAGEMENT)
5. Unit V (FILE SYSTEM)
6. Unit VI (INPUT OUTPUT SYSTEM)
This document provides an introduction and overview of operating systems. It defines an operating system as a program that acts as an intermediary between the user and computer hardware to effectively utilize system resources and make problem solving easier. A computer system consists of hardware, operating system, application programs, and users. The operating system coordinates access to resources, executes programs, handles input/output, manages files and directories, and provides protection and security for multi-user systems. It discusses the evolution of operating systems and provides examples of early systems like batch processing and timesharing systems.
Unleash the Power of Your Computer with a Deep Dive into Operating Systems
Explore the hidden world of operating systems, the software maestros that orchestrate your computer's resources. This presentation delves into:
Resource Management and Coordination - How the OS juggles processor, memory, and devices for optimal performance.
Prioritization, Protection, and Parallelism - Ensuring tasks run smoothly, data is secure, and operations can happen simultaneously.
Command Interpreters and the Boot Process - How to communicate with your OS and initiate computer startup.
File and Directory Management - Mastering the organization of your digital world in DOS, UNIX, and Windows 2000.
Get ready to unlock the secrets behind your computer's efficiency and become a more informed user!
The document discusses real-time operating systems (RTOS). It defines what an RTOS is and its key components: task management, memory management, intertask communication, and intertask synchronization. It also outlines the requirements of an RTOS, including being multi-tasking, preemptible, supporting task priorities and synchronization mechanisms, avoiding priority inversion, and being deterministic.
This document provides information about operating systems and their functions. It discusses that an operating system is software that manages computer hardware and software resources and provides common services for computer programs. It describes the main functions of an operating system including processor management, device management, memory management, and file management. It also discusses different types of operating systems such as single-user OS, multi-user OS, real-time OS, and distributed OS. Finally, it lists some commonly used operating systems like Windows, Linux, Android, iOS, and Symbian.
MYSQL DATABASE Operating System Part2 (1).pptxArjayBalberan1
The document provides an overview of different types of operating systems:
- Early computers used batch processing systems where users submitted jobs offline via punch cards and the computer processed them in batches.
- Multiprogramming systems allowed multiple programs to run simultaneously by quickly switching between them, improving resource usage compared to batch systems.
- Time-sharing systems further extended this by allowing many users to access a single computer simultaneously through rapid switching between terminals.
- Distributed systems connect multiple autonomous computers to work together and share workload, with examples including client-server, peer-to-peer, and middleware architectures.
The document discusses operating systems and processes. It defines an operating system as software that controls hardware and manages resources. A process is a program in execution that has a unique ID and state. Processes go through various states like running, ready, blocked/waiting, and terminated. Threads are lightweight processes that can be scheduled independently and share resources within a process. User-level threads are managed in libraries while kernel-level threads are managed by the operating system kernel.
The document discusses operating systems and processes. It defines an operating system as software that controls hardware and manages resources. A process is a program in execution that has a unique ID and state. Processes go through various states like running, ready, blocked/waiting, and terminated. Threads are lightweight processes that can be scheduled independently and share resources within a process. User-level threads are managed in libraries while kernel-level threads are managed by the operating system kernel.
This document provides an introduction and overview of operating systems. It defines an operating system as a program that manages computer hardware resources and provides common services for computer programs. It describes the four main components of a computer system: hardware, operating system, application programs, and users. It also outlines some of the key services an operating system provides, such as program execution, I/O operations, file management, and resource allocation. Finally, it discusses the structure and evolution of modern operating systems from early batch and time-sharing systems to current multiprogramming systems.
Mohsin Khan provides contact information for technical support on operating systems. The document discusses operating system definitions, functions including booting, user interfaces, resource management, file management and scheduling. It covers topics such as multiprogramming, multitasking, multiprocessing, types of operating systems, and installation of Windows 7.
An operating system acts as an intermediary between the user and computer hardware. It manages computer resources like memory and CPU time. It also provides abstractions for file management, user interfaces, and handles tasks like booting the computer, running programs concurrently, and allocating hardware resources. Key functions include resource allocation, running programs in parallel through concepts like multiprocessing and multitasking, handling input/output through spooling, and providing interfaces for users and applications.
Similar to Cs6413 operating-systems-laboratory (20)
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSIJNSA Journal
The smart irrigation system represents an innovative approach to optimize water usage in agricultural and landscaping practices. The integration of cutting-edge technologies, including sensors, actuators, and data analysis, empowers this system to provide accurate monitoring and control of irrigation processes by leveraging real-time environmental conditions. The main objective of a smart irrigation system is to optimize water efficiency, minimize expenses, and foster the adoption of sustainable water management methods. This paper conducts a systematic risk assessment by exploring the key components/assets and their functionalities in the smart irrigation system. The crucial role of sensors in gathering data on soil moisture, weather patterns, and plant well-being is emphasized in this system. These sensors enable intelligent decision-making in irrigation scheduling and water distribution, leading to enhanced water efficiency and sustainable water management practices. Actuators enable automated control of irrigation devices, ensuring precise and targeted water delivery to plants. Additionally, the paper addresses the potential threat and vulnerabilities associated with smart irrigation systems. It discusses limitations of the system, such as power constraints and computational capabilities, and calculates the potential security risks. The paper suggests possible risk treatment methods for effective secure system operation. In conclusion, the paper emphasizes the significant benefits of implementing smart irrigation systems, including improved water conservation, increased crop yield, and reduced environmental impact. Additionally, based on the security analysis conducted, the paper recommends the implementation of countermeasures and security approaches to address vulnerabilities and ensure the integrity and reliability of the system. By incorporating these measures, smart irrigation technology can revolutionize water management practices in agriculture, promoting sustainability, resource efficiency, and safeguarding against potential security threats.
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesChristina Lin
Traditionally, dealing with real-time data pipelines has involved significant overhead, even for straightforward tasks like data transformation or masking. However, in this talk, we’ll venture into the dynamic realm of WebAssembly (WASM) and discover how it can revolutionize the creation of stateless streaming pipelines within a Kafka (Redpanda) broker. These pipelines are adept at managing low-latency, high-data-volume scenarios.
A review on techniques and modelling methodologies used for checking electrom...nooriasukmaningtyas
The proper function of the integrated circuit (IC) in an inhibiting electromagnetic environment has always been a serious concern throughout the decades of revolution in the world of electronics, from disjunct devices to today’s integrated circuit technology, where billions of transistors are combined on a single chip. The automotive industry and smart vehicles in particular, are confronting design issues such as being prone to electromagnetic interference (EMI). Electronic control devices calculate incorrect outputs because of EMI and sensors give misleading values which can prove fatal in case of automotives. In this paper, the authors have non exhaustively tried to review research work concerned with the investigation of EMI in ICs and prediction of this EMI using various modelling methodologies and measurement setups.
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...IJECEIAES
Climate change's impact on the planet forced the United Nations and governments to promote green energies and electric transportation. The deployments of photovoltaic (PV) and electric vehicle (EV) systems gained stronger momentum due to their numerous advantages over fossil fuel types. The advantages go beyond sustainability to reach financial support and stability. The work in this paper introduces the hybrid system between PV and EV to support industrial and commercial plants. This paper covers the theoretical framework of the proposed hybrid system including the required equation to complete the cost analysis when PV and EV are present. In addition, the proposed design diagram which sets the priorities and requirements of the system is presented. The proposed approach allows setup to advance their power stability, especially during power outages. The presented information supports researchers and plant owners to complete the necessary analysis while promoting the deployment of clean energy. The result of a case study that represents a dairy milk farmer supports the theoretical works and highlights its advanced benefits to existing plants. The short return on investment of the proposed approach supports the paper's novelty approach for the sustainable electrical system. In addition, the proposed system allows for an isolated power setup without the need for a transmission line which enhances the safety of the electrical network
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...University of Maribor
Slides from talk presenting:
Aleš Zamuda: Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapter and Networking.
Presentation at IcETRAN 2024 session:
"Inter-Society Networking Panel GRSS/MTT-S/CIS
Panel Session: Promoting Connection and Cooperation"
IEEE Slovenia GRSS
IEEE Serbia and Montenegro MTT-S
IEEE Slovenia CIS
11TH INTERNATIONAL CONFERENCE ON ELECTRICAL, ELECTRONIC AND COMPUTING ENGINEERING
3-6 June 2024, Niš, Serbia
ACEP Magazine edition 4th launched on 05.06.2024Rahul
This document provides information about the third edition of the magazine "Sthapatya" published by the Association of Civil Engineers (Practicing) Aurangabad. It includes messages from current and past presidents of ACEP, memories and photos from past ACEP events, information on life time achievement awards given by ACEP, and a technical article on concrete maintenance, repairs and strengthening. The document highlights activities of ACEP and provides a technical educational article for members.
Introduction- e - waste – definition - sources of e-waste– hazardous substances in e-waste - effects of e-waste on environment and human health- need for e-waste management– e-waste handling rules - waste minimization techniques for managing e-waste – recycling of e-waste - disposal treatment methods of e- waste – mechanism of extraction of precious metal from leaching solution-global Scenario of E-waste – E-waste in India- case studies.
1. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 1
Dharmapuri – 636 703
Regulation : 2013
Branch : B.E. - CSE
Year & Semester : II Year / IV Semester
CS6413-OPERATING SYSTEM LABORATORY
LAB MANUAL
2. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 2
ANNA UNIVERSITY CHENNAI
REGULATION -2013
CS 6413 – OPERATING SYSTEMS LABORATORY
LIST OF EXPERIMENTS:
1. Basics of UNIX commands.
2. Shell programming
3. Implementation of CPU scheduling. a) Round Robin b) SJF c) FCFS d) Priority
4. Implement all file allocation strategies
5. Implement Semaphores
6. Implement ll File Organization Techniques a
7. Implement Bankers algorithm for Dead Lock Avoidance
8. Implement an Algorithm for Dead Lock Detection
9. Implement the all page replacement algorithms a) FIFO b) LRU c) LFU
10. Implement Shared memory and IPC
11. Implement Paging Technique f memory management.
12. Implement Threading & Synchronization Applications
Total hours: 45
3. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 3
INDEX
S.
NO DATE NAME OF THE EXPERIMENTS
SIGNATURE
OF THE
STAFF
REMARKS
1 Process System Calls
2 IO System Calls
3 First Come First Serve Scheduling
4 Shortest job first Scheduling
5 Priority Scheduling
6 Round Robin Scheduling
7 IPC using Pipe Processing
8
Producer-consumer problem Using
semaphores
9 First Fit For Memory Management
10 File Manipulation-I
11 File Manipulation-II
12
Simulate Page Replacement Algorithms
FIFO
13
Simulate Page Replacement Algorithms
LRU
14
Simulate Page Replacement Algorithms
OPTIMAL
15
Simulate Algorithm For Deadlock
Prevention
4. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 4
Operating System
Introduction
A computer system can be divided into 4 components:
- Hardware (CPU, memory, input/output devices, etc.),
- Operating system,
- System programs (word processors, spread sheets, accounting software’s, compilers,)
- Application programs.
In 1960’s definition of an operating system is “software that controls the hardware”.
However, today, due to microcode we need a better definition. We see an operating system as the
programs that make the hardware useable. In brief, an operating system is the set of programs that
controls a computer.
An Operating system is software that creates a relation between the User, Software and
Hardware. It is an interface between the all. All the computers need basic software known as an
Operating System (OS) to function.
The OS acts as an interface between the User, Application Programs, Hardware and the
System Peripherals. The OS is the first software to be loaded when a computers starts up. The
entire application programs are loaded after the OS.
Types of Operating System (Based of No. of user):
1. Single User: If the single user Operating System is loaded in computer’s memory; the
computer would be able to handle one user at a time.
Ex: MS-Dos, MS-Win 95-98, Win-ME
1. Multi user: If the multi-user Operating System is loaded in computer’s memory; the
computer would be able to handle more than one user at a time.
Ex: UNIX, Linux, XENIX
2. Network: If the network Operating System is loaded in computer’s memory; the
computer would be able to handle more than one computer at time.
Ex: Novel Netware, Win-NT, Win-2000-2003
5. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 5
Command Prompt Interface:
Operating System provides a text based interface called command prompt. From the
command prompt commands can be issued to perform file and disk management and to run
program. Results of these commands are presented to the user as text message.
C:>-
The command prompt can be an alphabet followed by one colon (:), one back slash (), one
greater than sign (>) and one blinking element called cursor (_).
Where C: represents the Drive letter (Current Drive)
represents the current folder / Directory
> represents the end of the Prompt and
_ blinking element (represents the Cursor)
CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 5
Command Prompt Interface:
Operating System provides a text based interface called command prompt. From the
command prompt commands can be issued to perform file and disk management and to run
program. Results of these commands are presented to the user as text message.
C:>-
The command prompt can be an alphabet followed by one colon (:), one back slash (), one
greater than sign (>) and one blinking element called cursor (_).
Where C: represents the Drive letter (Current Drive)
represents the current folder / Directory
> represents the end of the Prompt and
_ blinking element (represents the Cursor)
CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 5
Command Prompt Interface:
Operating System provides a text based interface called command prompt. From the
command prompt commands can be issued to perform file and disk management and to run
program. Results of these commands are presented to the user as text message.
C:>-
The command prompt can be an alphabet followed by one colon (:), one back slash (), one
greater than sign (>) and one blinking element called cursor (_).
Where C: represents the Drive letter (Current Drive)
represents the current folder / Directory
> represents the end of the Prompt and
_ blinking element (represents the Cursor)
6. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 6
Operating Systems Types
Single- And Multi-Tasking Operating Systems
A single-tasking system can only run one program at a time, while a multi-tasking
operating system allows more than one program to be running in concurrency. This is achieved by
time-sharing, dividing the available processor time between multiple processes that are each
interrupted repeatedly in time slices by a task-scheduling subsystem of the operating system.
Multi-tasking may be characterized in preemptive and co-operative types. In preemptive
multitasking, the operating system slices the CPU time and dedicates a slot to each of the
programs. Unix-like operating systems, e.g., Solaris, Linux, as well as AmigaOS support
preemptive multitasking.
Single- And Multi-User Operating Systems
Single-user operating systems have no facilities to distinguish users, but may allow
multiple programs to run in tandem. A multi-user operating system extends the basic concept of
multi-tasking with facilities that identify processes and resources, such as disk space, belonging to
multiple users, and the system permits multiple users to interact with the system at the same time.
Time-sharing operating systems schedule tasks for efficient use of the system and may also
include accounting software for cost allocation of processor time, mass storage, printing, and
other resources to multiple users.
Distributed Operating Systems
A distributed operating system manages a group of distinct computers and makes them
appear to be a single computer. The development of networked computers that could be linked
and communicate with each other gave rise to distributed computing. Distributed computations
are carried out on more than one machine. When computers in a group work in cooperation, they
form a distributed system.
Embedded Operating Systems
Embedded operating systems are designed to be used in embedded computer systems.
They are designed to operate on small machines like PDAs with less autonomy. They are able to
operate with a limited number of resources. They are very compact and extremely efficient by
design. Windows CE and “Minix 3”are some examples of embedded operating systems.
7. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 7
Real-Time Operating Systems
A real-time operating system is an operating system that guarantees to process events or
data by a specific moment in time. A real-time operating system may be single- or multi-tasking,
but when multitasking, it uses specialized scheduling algorithms so that a deterministic nature of
behavior is achieved. An event-driven system switches between tasks based on their priorities or
external events while time-sharing operating systems switch tasks based on clock interrupts
Process Scheduling
Processes are the Small Programs those are executed by the user according to
their Request. CPU Executes all the Process according to Some Rules or Some
Schedule. Scheduling ist hat in which each process have Some Amount of Time of
CPU. Scheduling Provides Time of CPU to the Each Process.
Types of Process Scheduling
1. FCFS Scheduling Algorithm
The First Come First Served (FCFS) Scheduling Algorithm is the simplest one. In this
algorithm the set of ready processes is managed as FIFO (first-in-first-out) Queue. The processes
are serviced by the CPU until completion in order of their entering in the FIFO queue.
A process once allocated the CPU keeps it until releasing the CPU either by terminating or
requesting I/O. For example, interrupted process is allowed to continujre running after interrupt
handling is done with.
2. SJF Scheduling Algorithm
The Shortest Job First Scheduling Algorithm chooses the process that has the smallest next
CPU burst.
3. SRTF: Shortest Remaining Time First
This is the preemptive version of SJF. The currently executing process will be preempted
from the CPU if a process with a shorter CPU burst time is arrived.
4. Round Robin Scheduling
This scheduling algorithm is designed especially for time sharing systems. It is similar to
FCFS scheduling, but preemption is added to switch between processes.
8. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 8
EX NO: 1
DATE:
PROCESS SYSTEM CALLS
AIM:
To write c program to implement the Process system calls.
ALGORITHM:
1. Start the program.
2. Declare the pid and get the pid by using the getpid() method.
3. Create a child process by calling the fork() system call
4. Check if(pid==0) then print the child process id and then print the parent process value.
Otherwise print
5. Stop the program
9. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 9
PROGRAM: (PROCESS SYSTEM CALLS)
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
void main(int argc,char *arg[])
{
int pid; pid=fork();
if(pid<0)
{
printf("fork failed");
exit(1);
}
else if(pid==0)
{
execlp("whoami","ls",NULL);
exit(0);
}
else
{
printf("n Process id is -%dn",getpid());
wait(NULL);
exit(0);
}
}
10. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 10
OUTPUT:
RESULT:
Thus the process system call program was executed and verified successfully.
11. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 11
EX.NO:2
DATE:
IO SYSTEM CALLS
AIM:
To write a ‘c’ program for I/O system calls.
ALGORITHM:
1. Start the program.
2. open a file for O_RDWR for R/W,O_CREATE for creating a file , O_TRUNC for
truncate a file
3. Using getchar(), read the character and stored in the string[] array
4. The string [] array is write into a file close it.
5. Then the first is opened for read only mode and read the characters and displayed It and
close the file
6. Stop the program
12. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 12
PROGRAM :( IO SYSTEM CALLS)
#include<stdio.h>
#include<unistd.h>
#include<string.h>
#include<fcntl.h>
main( )
{
int fd[2];
char buf1[25]= "just a testn";
char buf2[50];
fd[0]=open("file1",O_RDWR);
fd[1]=open("file2",O_RDWR);
write(fd[0], buf1, strlen(buf1));
printf("n Enter the text now….");
scanf("n %s",buf1);
printf("n Cat file1 is n hai");
write(fd[0], buf1, strlen(buf1));
lseek(fd[0], SEEK_SET, 0);
read(fd[0], buf2, sizeof(buf1));
write(fd[1], buf2, sizeof(buf2));
close(fd[0]);
close(fd[1]);
printf("n");
return 0;
}
13. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 13
OUTPUT:
RESULT:
Thus the I/O system call program was executed and verified successfully.
14. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 14
EX.NO:3
DATE:
FIRST COME FIRST SERVE SCHEDULING
AIM:
To write the program to implement CPU & scheduling algorithm for first come first serve
scheduling.
ALGORITHM:
1. Start the program.
2. Get the number of processes and their burst time.
3. Initialize the waiting time for process 1 and 0.
4. Process for(i=2;i<=n;i++),wt.p[i]=p[i-1]+bt.p[i-1].
5. The waiting time of all the processes is summed then average value time is calculated.
6. The waiting time of each process and average times are displayed
7. Stop the program
15. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 15
PROGRAM :( FIRST COME FIRST SERVE SCHEDULING)
#include<stdio.h>
struct process
{
int pid;
int bt;
int wt,tt;
}p[10];
int main()
{
int i,n,totwt,tottt,avg1,avg2; clrscr();
printf("enter the no of process n"); scanf("%d",&n);
for(i=1;i<=n;i++)
{
p[i].pid=i;
printf("enter the burst time n"); scanf("%d",&p[i].bt);
}
p[1].wt=0;
p[1].tt=p[1].bt+p[1].wt;
i=2;
while(i<=n)
{
p[i].wt=p[i-1].bt+p[i-1].wt; p[i].tt=p[i].bt+p[i].wt;
i ++;
}
i=1;
totwt=tottt=0;
printf("n processid t btt wtt ttn"); while(i<=n){
16. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 16
printf("nt%d t%d t%d t%d",p[i].pid,p[i].bt,p[i].wt,p[i].tt);
totwt=p[i].wt+totwt;
tottt=p[i].tt+tottt;
i++;}
avg1=totwt/n; avg2=tottt/n; printf("navg1=%d t avg2=%d
t",avg1,avg2); getch();
return 0;
}
OUTPUT:
enter the no of process 3
enter the burst time 2
enter the burst time 4
enter the burst time 6
Process sid bt wt tt
1 2 0 2
2 4 2 6
3 6 6 12
avg1=2 avg2=6
RESULT:
Thus the FIFO process scheduling program was executed and verified successfully.
17. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 17
EX.NO:4
DATE:
SHORTEST JOB FIRST SCHEDULING
AIM:
To write a program to implement cpu scheduling algorithm for shortest job first
scheduling.
ALGORITHM:
1. Start the program. Get the number of processes and their burst time.
2. Initialize the waiting time for process 1 as 0.
3. The processes are stored according to their burst time.
4. The waiting time for the processes are calculated a follows:
for(i=2;i<=n;i++).wt.p[i]=p[i=1]+bt.p[i-1].
5. The waiting time of all the processes summed and then the average time is calculate
6. The waiting time of each processes and average time are displayed.
7. Stop the program.
18. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 18
PROGRAM: (SHORTEST JOB FIRST SCHEDULING)
#include<stdio.h>
#include<conio.h>
struct process
{
int pid;
int bt;
int wt;
int tt;
}p[10],temp;
int main()
{
int i,j,n,totwt,tottt;
float avg1,avg2;
clrscr();
printf("nEnter the number of process:t");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
p[i].pid=i;
printf("nEnter the burst time:t");
scanf("%d",&p[i].bt);
}
for(i=1;i<n;i++){
for(j=i+1;j<=n;j++)
{
if(p[i].bt>p[j].bt)
{
temp.pid=p[i].pid;
19. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 19
p[i].pid=p[j].pid;
p[j].pid=temp.pid;
temp.bt=p[i].bt;p[i].bt=p[j].bt;
p[j].bt=temp.bt;
}}}
p[1].wt=0;
p[1].tt=p[1].bt+p[1].wt;
i=2;
while(i<=n){
p[i].wt=p[i-1].bt+p[i-1].wt;
p[i].tt=p[i].bt+p[i].wt;
i++;
}
i=1;
totwt=tottt=0;
printf("nProcess id tbt twt ttt");
while(i<=n){
printf("nt%d t%d t%d t%dn",p[i].pid,p[i].bt,p[i].wt,p[i].tt);
totwt=p[i].wt+totwt;
tottt=p[i].tt+tottt;
i++;
} avg1=totwt/n;
avg2=tottt/n;
printf("nAVG1=%ft AVG2=%f",avg1,avg2);
getch();
return 0; }
20. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 20
OUTPUT:
enter the number of process 3
enter the burst time: 2
enter the burst time: 4
enter the burst time: 6
processid bt wt tt
1 2 0 2
2 4 2 6
3 6 6 12
AVG1=2.000000 AVG2=6.000000
RESULT:
Thus the SJF program was executed and verified successfully
21. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 21
EX.NO:5
DATE:
PRIORITY SCHEDULING
AIM:
To write a ‘C’ program to perform priority scheduling.
ALGORITHM:
1. Start the program.
2. Read burst time, waiting time, turn the around time and priority.
3. Initialize the waiting time for process 1 and 0.
4. Based up on the priority process are arranged
5. The waiting time of all the processes is summed and then the average waiting time
6. The waiting time of each process and average waiting time are displayed based on the
priority.
7. Stop the program.
22. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 22
PROGRAM: (PRIORITY SCHEDULING)
#include<stdio.h>
#include<conio.h>
struct process
{
int pid;
int bt;
int wt;
int tt;
int prior;
}
p[10],temp;
int main()
{
int i,j,n,totwt,tottt,arg1,arg2;
clrscr();
printf("enter the number of process");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
p[i].pid=i;
printf("enter the burst time");
scanf("%d",&p[i].bt);
printf("n enter the priority");
scanf("%d",&p[i].prior);
}
for(i=1;i<n;i++)
{
for(j=i+1;j<=n;j++)
23. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 23
{
if(p[i].prior>p[j].prior)
{
temp.pid=p[i].pid;
p[i].pid=p[j].pid;
p[j].pid=temp.pid;
temp.bt=p[i].bt;
p[i].bt=p[j].bt;
p[j].bt=temp.bt;
temp.prior=p[i].prior;
p[i].prior=p[j].prior;
p[j].prior=temp.prior;
}
}
}
p[i].wt=0;
p[1].tt=p[1].bt+p[1].wt;
i=2;
while(i<=n)
{
p[i].wt=p[i-1].bt+p[i-1].wt;
p[i].tt=p[i].bt+p[i].wt;
i++;
}
i=1;
totwt=tottt=0;
printf("n process to t bt t wt t tt");
while(i<=n)
{
24. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 24
printf("n%dt %dt %dt %dt",p[i].pid,p[i].bt,p[i].wt,p[i].tt);
totwt=p[i].wt+totwt;
tottt=p[i].tt+tottt;
i++;
}
arg1=totwt/n;
arg2=tottt/n;
printf("n arg1=%d t arg2=%dt",arg1,arg2);
getch();
return 0;
}
25. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 25
OUTPUT:
enter the no of process:3
enter the burst time:2
enter the priority:3
enter the burst time:4
enter the priority:1
enter the burst time:6
enter the priority:2
process to bt wt tt
1 4 0 4 4
2 6 4 10 14
3 2 10 12 22
avg1=4 avg2=8
RESULT:
Thus the priority scheduling program was executed and verified successfully
26. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 26
EX.NO:6
DATE:
ROUND ROBIN SCHEDULING
AIM:
To write a program to implement cpu scheduling for Round Robin Scheduling.
ALGORITHM:
1. Get the number of process and their burst time.
2. Initialize the array for Round Robin circular queue as ‘0’.
3. The burst time of each process is divided and the quotients are stored on the round
Robin array.
4. According to the array value the waiting time for each process and the average
time are calculated as line the other scheduling.
5. The waiting time for each process and average times are displayed.
6. Stop the program.
27. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 27
PROGRAM :( ROUND ROBIN SCHEDULING)
#include<stdio.h>
#include<conio.h>
struct process
{
int pid,bt,tt,wt;
};
int main()
{
struct process x[10],p[30];
int i,j,k,tot=0,m,n;
float wttime=0.0,tottime=0.0,a1,a2;
clrscr();
printf("nEnter the number of process:t");
scanf("%d",&n);
for(i=1;i<=n;i++){
x[i].pid=i;
printf("nEnter the Burst Time:t");
scanf("%d",&x[i].bt);
tot=tot+x[i].bt;
}
printf("nTotal Burst Time:t%d",tot);
p[0].tt=0;
k=1;
printf("nEnter the Time Slice:t");
scanf("%d",&m);
for(j=1;j<=tot;j++)
{
for(i=1;i<=n;i++)
28. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 28
{
if(x[i].bt !=0)
{
p[k].pid=i;
if(x[i].bt-m<0)
{
p[k].wt=p[k-1].tt;
p[k].bt=x[i].bt;
p[k].tt=p[k].wt+x[i].bt;
x[i].bt=0;
k++;
}
else
{
p[k].wt=p[k-1].tt;
p[k].tt=p[k].wt+m;
x[i].bt=x[i].bt-m;
k++;
}
}
}
}
printf("nProcess id twt ttt");
for(i=1;i<k;i++){
printf("nt%d t%d t%d",p[i].pid,p[i].wt,p[i].tt);
wttime=wttime+p[i].wt;
tottime=tottime+p[i].tt;
a1=wttime/n;
a2=tottime/n;
29. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 29
}
printf("nnAverage Waiting Time:t%f",a1);
printf("nnAverage TurnAround Time:t%f",a2);
getch();
return 0;
}
30. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 30
OUTPUT:
enter the no of process3
enter the burst time3
enter the burst time5
enter the burst time7
total burst time : 15
enter the time slice: 2
process id wt tt
1 0 2
2 2 4
3 4 6
1 6 7
process id wt tt
2 7 9
3 9 11
2 11 12
3 12 14
3 14 15
avg waiting time: 21.666666
avg turnaround time: 26.666666
RESULT:
Thus the Round Robin scheduling program was executed and verified successfully.
31. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 31
EX.NO:7
DATE:
PIPE PROCESSING
AIM :
To write a program for create a pope processing
ALGORITHM:
1. Start the program.
2. Declare the variables.
3. Read the choice.
4. Create a piping processing using IPC.
5. Assign the variable lengths
6. “strcpy” the message lengths.
7. To join the operation using IPC .
8. Stop the program
.
32. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 32
PROGRAM :( PIPE PROCESSING)
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define MSG_LEN 64
int main(){
int result;
int fd[2];
char message[MSG_LEN];
char recvd_msg[MSG_LEN];
result = pipe (fd);
//Creating a pipe//fd[0] is for reading and fd[1] is for writing
if (result < 0)
{
perror("pipe ");
exit(1);
}
strncpy(message,"Linux World!! ",MSG_LEN);
result=write(fd[1],message,strlen(message));
if (result < 0)
{
perror("write");
exit(2);
}
strncpy(message,"Understanding ",MSG_LEN);
result=write(fd[1],message,strlen(message));
if (result < 0)
{
33. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 33
perror("write");
exit(2);
}
strncpy(message,"Concepts of ",MSG_LEN);
result=write(fd[1],message,strlen(message));
if (result < 0)
{
perror("write");
exit(2);
}
strncpy(message,"Piping ", MSG_LEN);
result=write(fd[1],message,strlen(message));
if (result < 0)
{
perror("write");
exit(2);
}
result=read (fd[0],recvd_msg,MSG_LEN);
if (result < 0)
{
perror("read");
exit(3);
}
printf("%sn",recvd_msg);
return 0;}
34. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 34
OUTPUT:
RESULT:
Thus the Piping process using IPC program was executed and verified successfully
35. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 35
EX.NO:8
DATE:
PRODUCER-CONSUMER PROBLEM USING SEMOPHERES
AIM:
To implement producer/consumer problem using semaphore.
ALGORITHM:
1. Declare variable for producer & consumer as pthread-t-tid produce tid consume.
2. Declare a structure to add items, semaphore variable set as struct.
3. Read number the items to be produced and consumed.
4. Declare and define semaphore function for creation and destroy.
5. Define producer function.
6. Define consumer function.
7. Call producer and consumer.
8. Stop the execution.
36. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 36
PROGRAM: (PRODUCER-CONSUMER PROBLEM)
#include<stdio.h>
void main()
{
int buffer[10], bufsize, in, out, produce, consume, choice=0;
in = 0;
out = 0;
bufsize = 10;
while(choice !=3)
{
printf("n1. Produce t 2. Consume t3. Exit");
printf("nEnter your choice: =");
scanf("%d", &choice);
switch(choice)
{
case 1: if((in+1)%bufsize==out)
printf("nBuffer is Full");
else
{
printf("nEnter the value: ");
scanf("%d", &produce);
buffer[in] = produce;
in = (in+1)%bufsize;
}
break;
case 2: if(in == out)
printf("nBuffer is Empty");
else
{
37. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 37
consume = buffer[out];
printf("nThe consumed value is %d", consume);
out = (out+1)%bufsize;
}
break;
} } }
OUTPUT:
1. Produce 2. Consume 3. Exit
Enter your choice: 2
Buffer is Empty
1. Produce 2. Consume 3. Exit
Enter your choice: 1
Enter the value: 100
1. Produce 2. Consume 3. Exit
Enter your choice: 2
The consumed value is 100
1. Produce 2. Consume 3. Exit
Enter your choice: 3
RESULT:
Thus the producer consumer program was executed and verified successfully
38. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 38
EX.NO:9
DATE:
FIRST FIT MEMORY MANAGEMENT
AIM:
To implement first fit, best fit algorithm for memory management.
ALGORITHM:
1. Start the program.
2. Get the segment size, number of process to be allocated and their corresponding size.
3. Get the options. If the option is ‘2’ call first fit function.
4. If the option is ‘1’ call best fit function. Otherwise exit.
5. For first fit, allocate the process to first possible segment which is free and set the
personnel slap as ‘1’. So that none of process to be allocated to segment which is already
allocated and vice versa.
6. For best fit, do the following steps,.
7. Sorts the segments according to their sizes.
8. Allocate the process to the segment which is equal to or slightly greater than the process
size and set the flag as the ‘1’ .So that none of the process to be allocated to the segment
which is already allocated and vice versa. Stop the program.
9. Stop the program
39. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 39
PROGRAM: (FIRST FIT MEMORY MANAGEMENT)
#include<stdio.h>
#include<conio.h>
#define max 25
void main()
{
int frag[max],b[max],f[max],i,j,nb,nf,temp,highest=0;
static int bf[max],ff[max];
clrscr();
printf("ntMemory Management Scheme - First Fit");
printf("nEnter the number of blocks:");
scanf("%d",&nb);
printf("Enter the number of files:");
scanf("%d",&nf);
printf("nEnter the size of the blocks:-n");
for(i=1;i<=nb;i++)
{
printf("Block %d:",i);
scanf("%d",&b[i]);
}
printf("Enter the size of the files :-n");
for(i=1;i<=nf;i++)
{
printf("File %d:",i);
scanf("%d",&f[i]);
}
for(i=1;i<=nf;i++)
{
40. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 40
for(j=1;j<=nb;j++)
{
if(bf[j]!=1) //if bf[j] is not allocated
{
temp=b[j]-f[i];
if(temp>=0)
if(highest<temp)
{
ff[i]=j;
highest=temp;
}
}
}
frag[i]=highest;
bf[ff[i]]=1;
highest=0;
}
printf("nFile_no:tFile_size :tBlock_no:tBlock_size:tFragement");
for(i=1;i<=nf;i++)
printf("n%dtt%dtt%dtt%dtt%d",
i,f[i],ff[i],b[ff[i]],frag[i]);
getch();
}
41. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 41
OUTPUT:
Enter the number of blocks: 3
Enter the number of files: 2
Enter the size of the blocks:-
Block 1: 5
Block 2: 2
Block 3: 7
Enter the size of the files:-
File 1: 1
File 2: 4
OUTPUT
File No File Size Block No Block Size Fragment
1 1 3 7 6
2 4 1 5 1
RESULT:
Thus the First Bit and Best Fit program was executed and verified successfully.
42. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 42
EX.NO:10
DATE:
FILE MANIPULATION-I
AIM:
To write a program for file manipulation for displays the file and directory in memory
ALGORITHM:
1. Start the program.
2. Use the pre defined function list out the files in directory..
3. Main function is used to check the file present in the directory or not.
4. Using the file pointer in the file to that the argument is less than a times means
print
5. By using if loop check in file, open two means print error
6. Stop the program.
43. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 43
PROGRAM: (FILE MANIPULATION-I)
#include <dirent.h>
#include <stdio.h>
int main(void)
{
DIR *d;
struct dirent *dir;
d = opendir(".");
if (d)
{
while ((dir = readdir(d)) != NULL)
{
printf("%sn", dir->d_name);
}
closedir(d);
}
return(0);
}
44. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 44
OUTPUT:
RESULT:
Thus the file management program was executed and verified successfully.
45. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 45
EX.NO:11
DATE:
FILE MANIPULATION-II
AIM:
To write a program performs file manipulation.
ALGORITHM:
1. Start the program.
2. Declare the arguments for file open and file create.
3. print the file in directory otherwise display the error message error in creation
4. if check the files in directory
5. close the files and directory
6. Stop the program.
46. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 46
PROGRAM :( FILE MANIPULATION-II)
#include<stdio.h>
#include<sys/stat.h>
#include<time.h>
main(int ag,char*arg[])
{
char buf[100];
struct stat s;
int fd1,fd2,n;
fd1=open(arg[1],0);
fd2=creat(arg[2],0777);
stat(arg[2],&s);
if(fd2==-1)
printf("ERROR IN CREATION");
while((n=read(fd1,buf,sizeof(buf)))>0)
{
if(write(fd2,buf,n)!=n)
{
close(fd1);
close(fd2);
}
}
printf("tn UID FOR FILE.......>%d n FILE ACCESS
TIME.....>%s n FILE MODIFIED TIME........>%s n FILE I-NODE
NUMBER......>%d n PERMISSION FOR
FILE.....>%onn",s.st_uid,ctime(&s.st_atime),ctime(&s.st_mt
ime),s.st_mode);
close(fd1);
close(fd2);
}
47. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 47
OUTPUT:
RESULT:
Thus the File Manipulation II program was executed and verified successfully.
CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 47
OUTPUT:
RESULT:
Thus the File Manipulation II program was executed and verified successfully.
CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 47
OUTPUT:
RESULT:
Thus the File Manipulation II program was executed and verified successfully.
48. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 48
EX NO: 12
DATE:
SIMULATE PAGE REPLACEMENT ALGORITHMS FIFO
AIM:
To Simulate FIFO page replacement algorithms.
ALGORITHM:
1. Start the program
2. Read the number of frames
3. Read the number of pages
4. Read the page numbers
5. Initialize the values in frames to -1
6. Allocate the pages in to frames in First in first out order.
7. Display the number of page faults.
8. Stop the program
49. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 49
PROGRAM: (SIMULATE PAGE REPLACEMENT ALGORITHMS FIFO)
#include<stdio.h>
#include<conio.h>
int i,j,nof,nor,flag=0,ref[50],frm[50],pf=0,victim=-1;
void main()
{
clrscr();
printf("n ttt FIFI PAGE REPLACEMENT ALGORITHM");
printf("n Enter no.of frames....");
scanf("%d",&nof);
printf("Enter number of Pages.n");
scanf("%d",&nor);
printf("n Enter the Page No...");
for(i=0;i<nor;i++)
scanf("%d",&ref[i]);
printf("nThe given Pages are:");
for(i=0;i<nor;i++)
printf("%4d",ref[i]);
for(i=1;i<=nof;i++)
frm[i]=-1;
printf("n");
for(i=0;i<nor;i++)
{
flag=0;
printf("nt page no %d->t",ref[i]);
for(j=0;j<nof;j++)
{
if(frm[j]==ref[i])
{
50. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 50
flag=1;
break;
}}
if(flag==0)
{
pf++;
victim++;
victim=victim%nof;
frm[victim]=ref[i];
for(j=0;j<nof;j++)
printf("%4d",frm[j]);
} }
printf("nntt No.of pages faults...%d",pf);
getch();
}
51. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 51
OUTPUT:
FIFO PAGE REPLACEMENT ALGORITHM
Enter no.of frames....4
Enter number of reference string..
6
Enter the reference string..
5 6 4 1 2 3
The given reference string:
...................................... 5 6 4 1 2 3
Reference np5-> 5 -1 -1 -1
Reference np6-> 5 6 -1 -1
Reference np4-> 5 6 4 -1
Reference np1-> 5 6 4 1
Reference np2-> 2 6 4 1
Reference np3-> 2 3 4 1
No.of pages faults...6
RESULT:
Thus the program FIFO page replacement was successfully executed.
52. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 52
EX NO:13
DATE :
SIMULATE PAGE REPLACEMENT ALGORITHMS: LRU
AIM:
To Simulate LRU page replacement algorithms
ALGORITHM:
1. Start
2. Read the number of frames
3. Read the number of pages
4. Read the page numbers
5. Initialize the values in frames to -1
6. Allocate the pages in to frames by selecting the page that has not been used for the longest
period of time.
7. Display the number of page faults.
8. stop
53. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 53
PROGRAM: (SIMULATE PAGE REPLACEMENT ALGORITHMS: LRU)
#include<stdio.h>
#include<conio.h>
int i,j,nof,nor,flag=0,ref[50],frm[50],pf=0,victim=-1;
int recent[10],lrucal[50],count=0;
int lruvictim();
void main()
{
clrscr();
printf("nttt LRU PAGE REPLACEMENT ALGORITHM");
printf("n Enter no.of Frames....");
scanf("%d",&nof);
printf(" Enter no.of reference string..");
scanf("%d",&nor);
printf("n Enter reference string..");
for(i=0;i<nor;i++)
scanf("%d",&ref[i]);
printf("nntt LRU PAGE REPLACEMENT ALGORITHM ");
printf("nt The given reference string:");
printf("n………………………………..");
for(i=0;i<nor;i++)
printf("%4d",ref[i]);
for(i=1;i<=nof;i++)
{
frm[i]=-1;
lrucal[i]=0;
}
for(i=0;i<10;i++)
54. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 54
recent[i]=0;
printf("n");
for(i=0;i<nor;i++)
{
flag=0;
printf("nt Reference NO %d->t",ref[i]);
for(j=0;j<nof;j++)
{
if(frm[j]==ref[i])
{
flag=1;
break;
}
}
if(flag==0)
{
count++;
if(count<=nof)
victim++;
else
victim=lruvictim();
pf++;
frm[victim]=ref[i];
for(j=0;j<nof;j++)
printf("%4d",frm[j]);
}
recent[ref[i]]=i;
55. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 55
}
printf("nnt No.of page faults...%d",pf);
getch();
}
int lruvictim()
{
int i,j,temp1,temp2;
for(i=0;i<nof;i++)
{
temp1=frm[i];
lrucal[i]=recent[temp1];
}
temp2=lrucal[0];
for(j=1;j<nof;j++)
{
if(temp2>lrucal[j])
temp2=lrucal[j];
}
for(i=0;i<nof;i++)
if(ref[temp2]==frm[i])
return i;
return 0;
}
56. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 56
OUTPUT:
LRU PAGE REPLACEMENT ALGORITHM
Enter no.of Frames....3
Enter no.of reference string..6
Enter reference string..
6 5 4 2 3 1
LRU PAGE REPLACEMENT ALGORITHM
The given reference string:
…………………. 6 5 4 2 3 1
Reference NO 6-> 6 -1 -1
Reference NO 5-> 6 5 -1
Reference NO 4-> 6 5 4
Reference NO 2-> 2 5 4
Reference NO 3-> 2 3 4
Reference NO 1-> 2 3 1
No.of page faults...6
RESULT:
Thus the process LRU page replacement was executed and verified successfully.
57. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 57
EX.NO:14
DATE:
SIMULATE PAGE REPLACEMENT ALGORITHMS: OPTIMAL
AIM:
To create program for optimal page replacement algorithms.
ALGORITHM:
1. Start the program
2. Read the number of frames
3. Read the number of pages
4. Read the page numbers
5. Initialize the values in frames to -1
6. Allocate the pages in to frames by selecting the page that will not be used for the
longest period of time.
7. Display the number of page faults.
8. Stop the program
58. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 58
PROGRAM: (SIMULATE PAGE REPLACEMENT ALGORITHMS: OPTIMAL)
#include<stdio.h>
#include<conio.h>
int i,j,nof,nor,flag=0,ref[50],frm[50],pf=0,victim=-1;
int recent[10],optcal[50],count=0;
int optvictim();
void main()
{
clrscr();
printf("n OPTIMAL PAGE REPLACEMENT ALGORITHN");
printf("n......................... ........");
printf("nEnter the no.of frames");
scanf("%d",&nof);
printf("Enter the no.of reference string");
scanf("%d",&nor);
printf("Enter the reference string");
for(i=0;i<nor;i++)
scanf("%d",&ref[i]);
clrscr();
printf("n OPTIMAL PAGE REPLACEMENT ALGORITHM");
printf("n................................");
printf("nThe given string");
printf("n....................n");
for(i=0;i<nor;i++)
printf("%4d",ref[i]);
for(i=0;i<nof;i++)
{
frm[i]=-1;
59. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 59
optcal[i]=0;
}
for(i=0;i<10;i++)
recent[i]=0;
printf("n");
for(i=0;i<nor;i++)
{
flag=0;
printf("ntref no %d ->t",ref[i]);
for(j=0;j<nof;j++)
{
if(frm[j]==ref[i])
{
flag=1;
break;
}
}
if(flag==0)
{
count++;
if(count<=nof)
victim++;
else
victim=optvictim(i);
pf++;
frm[victim]=ref[i];
for(j=0;j<nof;j++)
printf("%4d",frm[j]);
}
60. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 60
}
printf("n Number of page faults: %d",pf);
getch();
}
int optvictim(int index)
{
int i,j,temp,notfound;
for(i=0;i<nof;i++)
{
notfound=1;
for(j=index;j<nor;j++)
if(frm[i]==ref[j])
{
notfound=0;
optcal[i]=j;
break;
}
if(notfound==1)
return i;
}
temp=optcal[0];
for(i=1;i<nof;i++)
if(temp<optcal[i])
temp=optcal[i];
for(i=0;i<nof;i++)
if(frm[temp]==frm[i])
return i;
return 0;
}
61. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 61
OUTPUT:
OPTIMAL PAGE REPLACEMENT ALGORITHM
Enter no. of Frames....3
Enter no. of reference string..6
Enter reference string..
6 5 4 2 3 1
OPTIMAL PAGE REPLACEMENT ALGORITHM
The given reference string:
…………………. 6 5 4 2 3 1
Reference NO 6-> 6 -1 -1
Reference NO 5-> 6 5 -1
Reference NO 4-> 6 5 4
Reference NO 2-> 2 5 4
Reference NO 3-> 2 3 4
Reference NO 1-> 2 3 1
No.of page faults...6
RESULT:
Thus the process optimal page replacement was executed and verified
successfully.
62. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 62
EX NO: 15
DATE:
SIMULATE ALGORITHM FOR DEADLOCK PREVENTION
AIM:
To Simulate Algorithm for Deadlock prevention
ALGORITHM:
1. Start the program
2. Attacking Mutex condition: never grant exclusive access. But this may not be possible for
several resources.
3. Attacking preemption: not something you want to do.
4. Attacking hold and wait condition: make a process hold at the most 1 resource
5. At a time. Make all the requests at the beginning. Nothing policy. If you feel, retry.
6. Attacking circular wait: Order all the resources. Make sure that the requests are issued in
the
7. Correct order so that there are no cycles present in the resource graph. Resources
numbered 1 ... n.
8. Resources can be requested only in increasing
9. Order. i.e. you cannot request a resource whose no is less than any you may be holding.
10. Stop the program
63. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 63
PROGRAM: (SIMULATE ALGORITHM FOR DEADLOCK PREVENTION)
#include<stdio.h>
#include<conio.h>
int max[10][10], alloc[10][10], need[10][10];
int avail[10],i,j,p,r,finish[10]={0},flag=0;
int main()
{
clrscr( );
printf("nnSIMULATION OF DEADLOCK PREVENTION");
printf("Enter no. of processes, resources");
scanf("%d%d",&p,&r);printf("Enter allocation matrix");
for(i=0;i<p;i++)
for(j=0;j<r;j++)
scanf("%d",&alloc[i][j]);
printf("enter max matrix");
for(i=0;i<p;i++) /*reading the maximum matrix and availale matrix*/
for(j=0;j<r;j++)
scanf("%d",&max[i][j]);
printf("enter available matrix");
for(i=0;i<r;i++)
scanf("%d",&avail[i]);
for(i=0;i<p;i++)
for(j=0;j<r;j++)
need[i][j]=max[i][j]-alloc[i][j];
fun(); /*calling function*/
if(flag==0)
{
if(finish[i]!=1)
{
printf("nn Failing :Mutual exclusion");
64. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 64
for(j=0;j<r;j++)
{ /*checking for mutual exclusion*/
if(avail[j]<need[i][j])
avail[j]=need[i][j];
}fun();
printf("n By allocating required resources to process %d dead lock is
prevented ",i);
printf("nn lack of preemption");
for(j=0;j<r;j++)
{
if(avail[j]<need[i][j])
avail[j]=need[i][j];
alloc[i][j]=0;
}
fun( );
printf("nn daed lock is prevented by allocating needed resources");
printf(" n n failing:Hold and Wait condition ");
for(j=0;j<r;j++)
{
if(avail[j]<need[i][j])
avail[j]=need[i][j];
}
fun( );
printf("n AVOIDING ANY ONE OF THE CONDITION, U CAN PREVENT DEADLOCK");
}
}
getch( ); return 0;
}
fun()
{
while(1)
65. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 65
{
for(flag=0,i=0;i<p;i++)
{
if(finish[i]==0)
{
for(j=0;j<r;j++)
{
if(need[i][j]<=avail[j])
continue;
else
break;
}
if(j==r)
{
for(j=0;j<r;j++)
avail[j]+=alloc[i][j];
flag=1;
finish[i]=1;
}
}
}
if(flag==0)
break;
}return 0;
}
66. CS6413 OPERATING SYSTEM LAB
VVIT DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 66
OUTPUT:
SIMULATION OF DEADLOCK PREVENTION
Enter no. of processes, resources 3, 2
Enter allocation matrix 2 4 5
3 4 5
Enter max matrix4 3 4
5 6 1
Enter available matrix2
Failing: Mutual Exclusion
By allocating required resources to process dead is prevented
Lack of no preemption deadlock is prevented by allocating needed resources
Failing: Hold and Wait condition
RESULT:
Thus the program deadlock was executed successfully.