Practical No: 1 Aim: Demonstrate round - robin scheduling using threads.
|
|
- Alfred Cole
- 5 years ago
- Views:
Transcription
1 Practical No: 1 Aim: Demonstrate round - robin scheduling using threads. Source Code: RR.java import java.io.*; class job implements Runnable int process_id, no_of_instr,time_quantum; Thread t; job(int pid, int instr, int tq) process_id = pid; no_of_instr = instr; time_quantum = tq; t = new Thread(this); t.start(); public void run() try for(int i=1; i<=no_of_instr; i++) System.out.println("Executing instr no " + i + " of process " + process_id); Thread.sleep(time_quantum); System.out.println("Job " + process_id + " is over");
2 catch(interruptedexception e) System.out.println("The job has been interrupted..."); class RR public static void main(string args[]) try int process_id=100, time_quantum = 100; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter a user process starting number:"); process_id = Integer.parseInt(br.readLine()); System.out.println("Enter a time quantum(in millis):"); time_quantum = Integer.parseInt(br.readLine()); job j1 = new job(process_id, 10, time_quantum); job j2 = new job(++process_id, 6, time_quantum); job j3 = new job(++process_id, 8, time_quantum); catch(exception e) System.out.println("Some process failed to complete..."); System.out.println("Plz contact system admin...");
3 Output:
4 Practical No: 2 Aim: Demonstrate Priority scheduling using threads. Source Code: Priority.java import java.io.*; class job implements Runnable int process_id, no_of_instr,priority_value, time_quantum; Thread t; job(int pid, int instr, int prio, int tq) process_id = pid; no_of_instr = instr; time_quantum = tq; priority_value = prio; t = new Thread(this); t.setpriority(priority_value); t.start(); public void run() try for(int i=1; i<=no_of_instr; i++) process_id); System.out.println("Executing instr no " + i + " of process " + Thread.sleep(time_quantum);
5 System.out.println("Job " + process_id + " is over"); catch(interruptedexception e) System.out.println("The job has been interrupted..."); class Priority public static void main(string args[]) try int process_id=100, time_quantum = 100; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter a user process starting number:"); process_id = Integer.parseInt(br.readLine()); System.out.println("Enter a time quantum(in millis):"); time_quantum = Integer.parseInt(br.readLine()); job j1 = new job(++process_id, 8, 9, time_quantum); job j2 = new job(++process_id, 8, 1, time_quantum); job j3 = new job(++process_id, 8, 2, time_quantum); catch(exception e) System.out.println("Some process failed to complete...");
6 System.out.println("Plz contact system admin..."); Output:
7
8 Practical No: 3 Aim: Calculate Turn - around time for any scheduling algorithm. Source Code: turn_around_time.java import java.io.*; import java.util.*; //class job represents os process //each job has some number of instructions //OS assigns process id and time quantum class job implements Runnable int process_id, no_of_instr,time_quantum; long millis; Thread t; job(int pid, int instr, int tq) millis = System.currentTimeMillis(); process_id = pid; no_of_instr = instr; time_quantum = tq; t = new Thread(this); t.start(); public void run() try for(int i=1; i<=no_of_instr; i++)
9 process_id); System.out.println("Executing instr no " + i + " of process " + Thread.sleep(time_quantum); millis = System.currentTimeMillis() - millis; turn_around_time.millitime = turn_around_time.millitime + millis; System.out.println("Job " + process_id + " with " + no_of_instr + " instructions has completed in " + millis + " milliseconds"); catch(interruptedexception e) class turn_around_time static long millitime = 0; System.out.println("The job has been interrupted..."); static int process_id=100, time_quantum = 100; public static void main(string args[]) try BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter a user process starting number:"); process_id = Integer.parseInt(br.readLine()); System.out.println("Enter a time quantum(in millis):"); time_quantum = Integer.parseInt(br.readLine());
10 job j1 = new job(process_id, 15, time_quantum); job j2 = new job(++process_id, 7, time_quantum); job j3 = new job(++process_id, 10, time_quantum); Thread mainthread = Thread.currentThread(); mainthread.sleep(3000); System.out.println("Average turn around time = " + (millitime)/3.0f); catch(exception e) System.out.println("Some process failed to complete..."); System.out.println("Plz contact system admin..."); Output:
11 Practical No: 4 Aim: Demonstrate the concept of synchronized access to shared resource. Source Code: //Demonstrate the concept of synchronized access to shared resource class room public synchronized void takeslecture(string name) throws InterruptedException System.out.println(name + " enters..."); Thread.sleep(250); System.out.println(name + " starts lecture..."); Thread.sleep(500); System.out.println(name + " exits..."); Thread.sleep(250); class lecturer implements Runnable String name; room r; Thread t; lecturer(string n,room r) name = n; t = new Thread(this, n); this.r = r; public void start()
12 t.start(); public void run() try r.takeslecture(name); catch(interruptedexception e) System.out.println(name + " operation interrupted..."); class synch_access public static void main(string args[]) room r = new room(); lecturer ABC= new lecturer("abc Sir",r); lecturer MNO= new lecturer("mno Madam",r); lecturer PQR = new lecturer("pqr",r); ABC.start(); MNO.start(); PQR.start();
13 Output:
14 Practical No: 5 Aim: Demonstrate any 1 of deadlock-avoidance algorithm Source Code: deadlock_avoidance.java import java.io.*; class Banker int avail[]; int max[][] = 3,2,2,1, 8,12,0,0, 2,1,0,0, 4,3,0,0, 2,0,3,1; int alloc[][] = 1,1,1,0, 2,1,0,0, 1,0,0,0, 2,1,0,0, 1,0,0,0; int need[][]; int m,n; Banker() m = 4; n = 5; avail = new int[4]; avail[0] = 16; // Number of Registers avail[1] = 50; // Number of Files avail[2] = 5; // Number of Ports avail[3] = 2; // Number of Printer need = new int[5][4]; for(int i=0;i<5; i++) for(int j=0;j<4; j++) need[i][j] = max[i][j] - alloc[i][j]; boolean issafe()
15 int work[] = new int[m]; boolean finish[] = new boolean[n]; for(int i=0 ;i<m; i++) work[i] = avail[i]; for(int i=0 ;i<n; i++) finish[i] = false; for(int i=0; i<n; i++) if(finish[i]==false) boolean incomplete=false; for(int j=0;j<m; j++) if(need[i][j]>work[j]) incomplete = true; work[j]); //System.out.println(i + ":" + j + ":" + need[i][j] + ":" + if(need[i][j]!=0 && need[i][j]<=work[j]) work[j] = work[j] - need[i][j]; if(!incomplete) finish[i]=true; if(finish[i])
16 System.out.println("Process " + i + " can be completed"); else System.out.println("Process " + i + " can't be completed"); for(int i=0; i<n; i++) if(!finish[i]) return false; return true; void resourcerequest() int request[][] = 1,1,1,0, 2,2,0,0, 1,1,0,1, 1,1,0,0, 1,0,0,0; boolean safe=true; for(int i=0; i<n; i++) for(int j=0;j<m; j++) if(request[i][j]<=need[i][j]) if(request[i][j]<=avail[j]) avail[j] = avail[j] - request[i][j]; alloc[i][j] = alloc[i][j] + request[i][j];
17 need[i][j] = need[i][j] - request[i][j]; else System.out.println("Hey process " + i + "! resource " + j + " is not available now...try again later..."); else System.out.println("Process " + i + " has exceeded request for resource " + j + " hence is unsafe"); if(safe) else class deadlock_avoidance safe = false; System.out.println("the system is safe..."); System.out.println("the system is unsafe..."); public static void main(string args[]) throws Exception
18 Banker b = new Banker(); System.out.println("Applying safety algorithm..."); if(b.issafe()) System.out.println("The system is in safe state..."); else System.out.println("The system is not in safe state..."); System.out.println("Applying resource request algo..."); b.resourcerequest(); Output:
19 Practical No: 6 Aim: Demonstrate memory management using first/best/worst fit Source Code: memory_management.java import java.util.*; import java.io.*; class Job int instr[]; int process_id, size; Job(int pid, int n) process_id = pid; size = n; instr = new int[size]; for(int i=0;i<size;i++) int getsize() return size; int [] getinstr() return instr; int getprocessid() instr[i] = process_id + i+1;
20 return process_id; class MemMgmt int memory_array[]; Vector jobqueue; MemMgmt(Vector v) jobqueue = v; memory_array = new int[20]; for(int i=0;i<20;i++) memory_array[i] = 0; System.out.println("Initial memory layout..."); printarray(); void addjob(job newjob) jobqueue.add(newjob); void addsortedjob(job newjob) if(jobqueue.size()==0) jobqueue.add(newjob);
21 return; for(int i=0; i<jobqueue.size(); i++) Job j = (Job) jobqueue.elementat(i); if(j.getsize()>=newjob.getsize()) jobqueue.insertelementat(newjob,i); return; jobqueue.add(newjob); void printarray() System.out.println(); System.out.print(" "); for(int i=0;i<20;i++) System.out.print(memory_array[i]+" "); void firstfit() int mem_arr_index=0; for(int i=0; i<jobqueue.size(); i++) Job job = (Job) jobqueue.elementat(i);
22 int instr_array[] = job.getinstr(); if(20-mem_arr_index>=instr_array.length) System.out.print("\n\ncopying " + instr_array.length + " instructions at location " + mem_arr_index); is too big!"); void worstfit() for(int j=0;j<instr_array.length;j++) printarray(); else int mem_arr_index=0; memory_array[mem_arr_index] = instr_array[j]; mem_arr_index++; for(int i=jobqueue.size()-1; i>=0; i--) System.out.println("\nJob with process id " + job.getprocessid()+ " Job job = (Job) jobqueue.elementat(i); int instr_array[] = job.getinstr(); if(20-mem_arr_index>=instr_array.length)
23 System.out.print("\n\ncopying " + instr_array.length + " instructions at location " + mem_arr_index); big!"); else class memory_management for(int j=0;j<instr_array.length;j++) printarray(); memory_array[mem_arr_index] = instr_array[j]; mem_arr_index++; System.out.println("\nJob with process id " + job.getprocessid()+ " is too public static void main(string args[]) throws Exception Vector v = new Vector(); MemMgmt m = new MemMgmt(v); Job job1 = new Job(500, 9); Job job2 = new Job(200, 2); Job job3 = new Job(900, 6); System.out.println("\n\nEnter policy:\n1:first Fit\n2:Best Fit\n3:Worst Fit"); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int policy=integer.parseint(br.readline());
24 if(policy==1) System.out.println("\nApplying First Fit Policy..."); m.addjob(job1); m.addjob(job2); m.addjob(job3); m.firstfit(); else if(policy==2) System.out.println("\nApplying Best Fit Policy..."); m.addsortedjob(job1); m.addsortedjob(job2); m.addsortedjob(job3); //m.bestfit(); else if(policy==3) System.out.println("\nApplying Worst Fit Policy..."); m.addsortedjob(job1); m.addsortedjob(job2); m.addsortedjob(job3); m.worstfit(); Output:
25
package p1; public class Derivation extends Protection { public Derivation() { System.out.println("Derived class constructor");
PROGRAM:1 WAP to implement the packages //package 1: package p1; public class Protection int n=1; public int n_pub=2; private int n_pri=3; protected int n_pro=4; public Protection () System.out.println("Base
More informationLe L c e t c ur u e e 7 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Multithreading
Course Name: Advanced Java Lecture 7 Topics to be covered Multithreading Thread--An Introduction Thread A thread is defined as the path of execution of a program. It is a sequence of instructions that
More informationJAVA. Lab 12 & 13: Multithreading
JAVA Prof. Navrati Saxena TA: Rochak Sachan Lab 12 & 13: Multithreading Outline: 2 What is multithreaded programming? Thread model Synchronization Thread Class and Runnable Interface The Main Thread Creating
More informationFIFO PAGE REPLACEMENT : import java.io.*; public class FIFO {
FIFO PAGE REPLACEMENT : import java.io.*; public class FIFO public static void main(string[] args) throws IOException BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int frames,
More information04-Java Multithreading
04-Java Multithreading Join Google+ community http://goo.gl/u7qvs You can ask all your doubts, questions and queries by posting on this G+ community during/after webinar http://openandroidlearning.org
More informationRecursion. General Algorithm for Recursion. When to use and not use Recursion. Recursion Removal. Examples
Recursion General Algorithm for Recursion When to use and not use Recursion Recursion Removal Examples Comparison of the Iterative and Recursive Solutions Exercises Unit 19 1 General Algorithm for Recursion
More informationModule - 4 Multi-Threaded Programming
Terminologies Module - 4 Multi-Threaded Programming Process: A program under execution is called as process. Thread: A smallest component of a process that can be executed independently. OR A thread is
More informationBufferedReader br = new BufferedReader(new InputStreamReader(System.in));
2.A. Design a superclass called Staff with details as StaffId, Name, Phone, Salary. Extend this class by writing three subclasses namely Teaching (domain, publications), Technical (skills), and Contract
More informationUnit - IV Multi-Threading
Unit - IV Multi-Threading 1 Uni Processing In the early days of computer only one program will occupy the memory. The second program must be in waiting. The second program will be entered whenever first
More informationMultithreaded Programming
Multithreaded Programming Multithreaded programming basics Concurrency is the ability to run multiple parts of the program in parallel. In Concurrent programming, there are two units of execution: Processes
More informationLast Class: Deadlocks. Today
Last Class: Deadlocks Necessary conditions for deadlock: Mutual exclusion Hold and wait No preemption Circular wait Ways of handling deadlock Deadlock detection and recovery Deadlock prevention Deadlock
More informationSynchronization synchronization.
Unit 4 Synchronization of threads using Synchronized keyword and lock method- Thread pool and Executors framework, Futures and callable, Fork-Join in Java. Deadlock conditions 1 Synchronization When two
More informationWhat is a Thread? Individual and separate unit of execution that is part of a process. multiple threads can work together to accomplish a common goal
Java Threads What is a Thread? Individual and separate unit of execution that is part of a process multiple threads can work together to accomplish a common goal Video Game example one thread for graphics
More informationNote: Each loop has 5 iterations in the ThreeLoopTest program.
Lecture 23 Multithreading Introduction Multithreading is the ability to do multiple things at once with in the same application. It provides finer granularity of concurrency. A thread sometimes called
More informationUnit 4. Thread class & Runnable Interface. Inter Thread Communication
Unit 4 Thread class & Runnable Interface. Inter Thread Communication 1 Multithreaded Programming Java provides built-in support for multithreaded programming. A multithreaded program contains two or more
More informationAssignment2013 Please use this document only for verifying if your programs are right. Do not blindly copy paste and waste your time.
Please use this document only for verifying if your programs are right. Do not blindly copy paste and waste your time. 11/3/2013 TechSparx Computer Training Center Saravanan.G Please use this document
More informatione) Implicit and Explicit Type Conversion Pg 328 j) Types of errors Pg 371
Class IX HY 2013 Revision Guidelines Page 1 Section A (Power Point) Q1.What is PowerPoint? How are PowerPoint files named? Q2. Describe the 4 different ways of creating a presentation? (2 lines each) Q3.
More informationINFO Ass 4. Exercise 1
Exercise 1 INFO 408 - Ass 4 public class UserInfo public static final long TIME_OUT = 1000 * 3000 ; public String user; public long id; public long creationdate; public UserInfo(String user,long id) this.user
More informationMultithreaded Programming
core programming Multithreaded Programming 1 2001-2003 Marty Hall, Larry Brown http:// 2 Multithreaded Programming Agenda Why threads? Approaches for starting threads Separate class approach Callback approach
More informationThe deadlock problem
Deadlocks Arvind Krishnamurthy Spring 2004 The deadlock problem A set of blocked processes each holding a resource and waiting to acquire a resource held by another process. Example locks A and B P 0 P
More informationGlobalLogic Technical Question Paper
GlobalLogic Technical Question Paper What is the output of the following code when compiled and run? Select two correct answers. public class Question01 { public static void main(string[] args){ int y=0;
More information7. MULTITHREDED PROGRAMMING
7. MULTITHREDED PROGRAMMING What is thread? A thread is a single sequential flow of control within a program. Thread is a path of the execution in a program. Muti-Threading: Executing more than one thread
More informationMYcsvtu Notes. Java Programming Lab Manual
Java Programming Lab Manual LIST OF EXPERIMENTS 1. Write a Program to add two numbers using Command Line Arguments. 2. Write a Program to find the factorial of a given number using while statement. 3.
More informationThreads Chate Patanothai
Threads Chate Patanothai Objectives Knowing thread: 3W1H Create separate threads Control the execution of a thread Communicate between threads Protect shared data C. Patanothai Threads 2 What are threads?
More informationOperating Systems: Quiz2 December 15, Class: No. Name:
Operating Systems: Quiz2 December 15, 2006 Class: No. Name: Part I (30%) Multiple Choice Each of the following questions has only one correct answer. Fill the correct one in the blank in front of each
More informationSoftware Practice 1 - Multithreading
Software Practice 1 - Multithreading What is the thread Life cycle of thread How to create thread Thread method Lab practice Prof. Joonwon Lee T.A. Jaehyun Song Jongseok Kim T.A. Sujin Oh Junseong Lee
More informationCOMP346 Winter Tutorial 4 Synchronization Semaphores
COMP346 Winter 2015 Tutorial 4 Synchronization Semaphores 1 Topics Synchronization in Details Semaphores Introducing Semaphore.java 2 Synchronization What is it? An act of communication between unrelated
More informationCSCD 330 Network Programming
CSCD 330 Network Programming Lecture 12 More Client-Server Programming Winter 2019 Reading: References at end of Lecture 1 Introduction So far, Looked at client-server programs with Java Sockets TCP and
More informationModule 7: Deadlocks. The Deadlock Problem
Module 7: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock Combined Approach to Deadlock
More informationModule 7: Deadlocks. System Model. Deadlock Characterization. Methods for Handling Deadlocks. Deadlock Prevention. Deadlock Avoidance
Module 7: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock Combined Approach to Deadlock
More informationDeadlock. Only one process can use the resource at a time but once it s done it can give it back for use by another process.
Deadlock A set of processes is deadlocked if each process in the set is waiting for an event that can be caused by another process in the set. The events that we are mainly concerned with are resource
More informationLast Class: Synchronization Problems. Need to hold multiple resources to perform task. CS377: Operating Systems. Real-world Examples
Last Class: Synchronization Problems Reader Writer Multiple readers, single writer In practice, use read-write locks Dining Philosophers Need to hold multiple resources to perform task Lecture 10, page
More informationMultithread Computing
Multithread Computing About This Lecture Purpose To learn multithread programming in Java What You Will Learn ¾ Benefits of multithreading ¾ Class Thread and interface Runnable ¾ Thread methods and thread
More informationCMSC 412. Announcements
CMSC 412 Deadlock Reading Announcements Chapter 7 Midterm next Monday In class Will have a review on Wednesday Project 3 due Friday Project 4 will be posted the same day 1 1 The Deadlock Problem A set
More informationSystem Model. Types of resources Reusable Resources Consumable Resources
Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock System Model Types
More informationAnimation Part 2: MoveableShape interface & Multithreading
Animation Part 2: MoveableShape interface & Multithreading MoveableShape Interface In the previous example, an image was drawn, then redrawn in another location Since the actions described above can apply
More informationMultithreading Pearson Education, Inc. All rights reserved.
1 23 Multithreading 2 23.1 Introduction Multithreading Provides application with multiple threads of execution Allows programs to perform tasks concurrently Often requires programmer to synchronize threads
More informationConcurrent Computing CSCI 201 Principles of Software Development
Concurrent Computing CSCI 201 Principles of Software Development Jeffrey Miller, Ph.D. jeffrey.miller@usc.edu Outline Threads Multi-Threaded Code CPU Scheduling Program USC CSCI 201L Thread Overview Looking
More informationJAVA - MULTITHREADING
JAVA - MULTITHREADING http://www.tutorialspoint.com/java/java_multithreading.htm Copyright tutorialspoint.com Java is amultithreaded programming language which means we can develop mult it hreaded program
More informationResource Management and Deadlocks 43
Resource Management and Deadlocks 43 The Deadlock Problem Law passed by the Kansas Legislature in early 20th century: When two trains approach each other at a crossing, both shall come to a full stop and
More informationCS307 Operating Systems Deadlocks
CS307 Deadlocks Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2016 Bridge Crossing Example Traffic only in one direction Each section of a bridge can be viewed
More informationUNIT IV MULTITHREADING AND GENERIC PROGRAMMING
UNIT IV MULTITHREADING AND GENERIC PROGRAMMING Differences between multithreading and multitasking, thread life cycle, creating threads, creating threads, synchronizing threads, Inter-thread communication,
More informationReading from URL. Intent - open URL get an input stream on the connection, and read from the input stream.
Simple Networking Loading applets from the network. Applets are referenced in a HTML file. Java programs can use URLs to connect to and retrieve information over the network. Uniform Resource Locator (URL)
More informationDeadlocks. Bridge Crossing Example. The Problem of Deadlock. Deadlock Characterization. Resource-Allocation Graph. System Model
CS07 Bridge Crossing Example Deadlocks Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2016 Traffic only in one direction Each section of a bridge can be viewed
More informationCSC Operating Systems Fall Lecture - XII Deadlocks - III. Tevfik Ko!ar. Louisiana State University. October 6 th, 2009
CSC 4103 - Operating Systems Fall 2009 Lecture - XII Deadlocks - III Tevfik Ko!ar Louisiana State University October 6 th, 2009 1 Deadlock Detection Allow system to enter deadlock state Detection algorithm
More informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2017 Lecture 17 Deadlock Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Claim edge may request- request
More informationCOMP31212: Concurrency A Review of Java Concurrency. Giles Reger
COMP31212: Concurrency A Review of Java Concurrency Giles Reger Outline What are Java Threads? In Java, concurrency is achieved by Threads A Java Thread object is just an object on the heap, like any other
More informationDeadlock. A Bit More on Synchronization. The Deadlock Problem. Deadlock Characterization. Operating Systems 2/7/2005. CSC 256/456 - Spring
A Bit More on Synchronization Deadlock CS 256/456 Dept. of Computer Science, University of Rochester Synchronizing interrupt handlers: Interrupt handlers run at highest priority and they must not block.
More informationCSCD 330 Network Programming
CSCD 330 Network Programming Lecture 12 More Client-Server Programming Winter 2016 Reading: References at end of Lecture 1 Introduction So far, Looked at client-server programs with Java Sockets TCP and
More informationCS360 Lecture 12 Multithreading
CS360 Lecture 12 Multithreading Thursday, March 11, 2004 Reading Multithreading: Chapter 16 Thread States At any time, a thread can be in one of several thread states: - Born: this is the time when the
More informationObject Oriented Programming (II-Year CSE II-Sem-R09)
(II-Year CSE II-Sem-R09) Unit-VI Prepared By: A.SHARATH KUMAR M.Tech Asst. Professor JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY, HYDERABAD. (Kukatpally, Hyderabad) Multithreading A thread is a single sequential
More informationPotential Deadlock Example
Deadlock Handling Notice: The slides for this lecture have been largely based on those accompanying an earlier edition of the course text Operating Systems Concepts, 9th ed., by Silberschatz, Galvin, and
More informationRoadmap. Safe State. Deadlock Avoidance. Basic Facts. Safe, Unsafe, Deadlock State. Tevfik Koşar. CSC Operating Systems Spring 2007
CSC 4103 - Operating Systems Spring 2007 Roadmap Lecture - IX Deadlocks - II Deadlocks Deadlock Avoidance Deadlock Detection Recovery from Deadlock Tevfik Koşar Louisiana State University February 15 th,
More informationcsci 3411: Operating Systems
csci 3411: Operating Systems Deadlocks Gabriel Parmer Slides evolved from Silberschatz and West Deadlocks:Synchronization Gone Wild A set of blocked processes each Hold a resource (critical section, using
More informationMultithreaded Programming
Multithreaded Programming http://www.motifake.com/multi-tasking-baby-dishes-bath-wash-demotivational-posters-118837.html Traditional Multi-tasking - One CPU - Many users, each wishing to use a computer
More informationSystem Programming. Practical Session 4: Threads and Concurrency / Safety
System Programming Practical Session 4: Threads and Concurrency / Safety Using Threads - All the computer programs you've seen so far were sequential only one thing was performed at any given time - Sometimes
More informationAmity School of Engineering
Amity School of Engineering B.Tech., CSE(5 th Semester) Java Programming Topic: Multithreading ANIL SAROLIYA 1 Multitasking and Multithreading Multitasking refers to a computer's ability to perform multiple
More informationDeadlock Prevention. Restrain the ways request can be made. Mutual Exclusion not required for sharable resources; must hold for nonsharable resources.
Deadlock Prevention Restrain the ways request can be made. Mutual Exclusion not required for sharable resources; must hold for nonsharable resources. Hold and Wait must guarantee that whenever a process
More informationOverview. Processes vs. Threads. Computation Abstractions. CMSC 433, Fall Michael Hicks 1
CMSC 433 Programming Language Technologies and Paradigms Spring 2003 Threads and Synchronization April 1, 2003 Overview What are threads? Thread scheduling, data races, and synchronization Thread mechanisms
More informationLast Class: Synchronization Problems!
Last Class: Synchronization Problems! Reader Writer Multiple readers, single writer In practice, use read-write locks Dining Philosophers Need to hold multiple resources to perform task Lecture 11, page
More informationOperating Systems. Deadlocks. Stephan Sigg. November 30, Distributed and Ubiquitous Systems Technische Universität Braunschweig
Operating Systems Deadlocks Stephan Sigg Distributed and Ubiquitous Systems Technische Universität Braunschweig November 30, 2010 Stephan Sigg Operating Systems 1/86 Overview and Structure Introduction
More informationDeadlocks. Operating System Concepts - 7 th Edition, Feb 14, 2005
Deadlocks Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock 7.2 Silberschatz,
More informationLecture 03: Thread API (continue)
Lecture 03: Thread API (continue) SSC2 Behzad Bordbar School of Computer Science, University of Birmingham, UK Lecture 03 1 Recap Extending Thread or implementing Runnable Thread terminology Stopping Threads
More informationChapter 7: Deadlocks. Operating System Concepts 8th Edition, modified by Stewart Weiss
Chapter 7: Deadlocks, Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance (briefly) Deadlock Detection
More informationJava Threads. COMP 585 Noteset #2 1
Java Threads The topic of threads overlaps the boundary between software development and operation systems. Words like process, task, and thread may mean different things depending on the author and the
More informationMultithreaded Programming
Multithreaded Programming http://www.motifake.com/multi-tasking-baby-dishes-bath-wash-demotivational-posters-118837.html http://thechive.com/2014/01/15/champions-of-multitasking-35-photos/ www.funscrape.com/meme/62260
More informationCS420: Operating Systems. Deadlocks & Deadlock Prevention
Deadlocks & Deadlock Prevention James Moscola Department of Physical Sciences York College of Pennsylvania Based on Operating System Concepts, 9th Edition by Silberschatz, Galvin, Gagne The Deadlock Problem
More informationChapter - 4. Deadlocks Important Questions
Chapter - 4 Deadlocks Important Questions 1 1.What do you mean by Deadlocks? A process request for some resources. If the resources are not available at that time, the process enters a waiting state. The
More informationCOMP 300E Operating Systems Fall Semester 2011 Midterm Examination SAMPLE. Name: Student ID:
COMP 300E Operating Systems Fall Semester 2011 Midterm Examination SAMPLE Time/Date: 5:30 6:30 pm Oct 19, 2011 (Wed) Name: Student ID: 1. Short Q&A 1.1 Explain the convoy effect with FCFS scheduling algorithm.
More informationMidterm assessment - MAKEUP Fall 2010
M257 MTA Faculty of Computer Studies Information Technology and Computing Date: /1/2011 Duration: 60 minutes 1-Version 1 M 257: Putting Java to Work Midterm assessment - MAKEUP Fall 2010 Student Name:
More informationJAVA and J2EE UNIT - 4 Multithreaded Programming And Event Handling
JAVA and J2EE UNIT - 4 Multithreaded Programming And Event Handling Multithreaded Programming Topics Multi Threaded Programming What are threads? How to make the classes threadable; Extending threads;
More informationResource Management and Deadlocks 1
Resource Management and Deadlocks 1 The Deadlock Problem Law passed by the Kansas Legislature in early 20th century: When two trains approach each other at a crossing, both shall come to a full stop and
More informationCS 351 Design of Large Programs Threads and Concurrency
CS 351 Design of Large Programs Threads and Concurrency Brooke Chenoweth University of New Mexico Spring 2018 Concurrency in Java Java has basic concurrency support built into the language. Also has high-level
More informationMultithreading using Java. Dr. Ferdin Joe John Joseph
Multithreading using Java Dr. Ferdin Joe John Joseph 1 Agenda Introduction Thread Applications Defining Threads Java Threads and States Priorities Accessing Shared Resources Synchronisation Assignment
More informationChapter 7: Deadlocks. Operating System Concepts 9th Edition DM510-14
Chapter 7: Deadlocks Chapter 7: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock 7.2 Chapter
More informationCOMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette
COMP 250: Java Programming I Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette Variables and types [Downey Ch 2] Variable: temporary storage location in memory.
More informationMultiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks)
M257 MTA Spring2010 Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks) 1. If we need various objects that are similar in structure, but
More informationCHAPTER 7 - DEADLOCKS
CHAPTER 7 - DEADLOCKS 1 OBJECTIVES To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks To present a number of different methods for preventing
More informationEastern Mediterranean University School of Computing and Technology Department of Information Technology. ITEC202 Operating Systems
Page 1 of 8 ITEC202 Operating Systems, Midterm Exam Eastern Mediterranean University School of Computing and Technology Department of Information Technology ITEC202 Operating Systems ITEC 202 Midterm Examination
More information4. Finding & Displaying Record of Salesman with minimum net income. 5. Finding & Displaying Record of Salesman with maximum net income.
Solution of problem#55 of Lab Assignment Problem Statement: Design & Implement a java program that can handle salesmen records of ABC Company. Each salesman has unique 4 digit id #, name, salary, monthly
More informationICS Principles of Operating Systems. Lectures Set 5- Deadlocks Prof. Nalini Venkatasubramanian
ICS 143 - Principles of Operating Systems Lectures Set 5- Deadlocks Prof. Nalini Venkatasubramanian nalini@ics.uci.edu Outline System Model Deadlock Characterization Methods for handling deadlocks Deadlock
More informationProgram 20: //Design an Applet program to handle Mouse Events. import java.awt.*; import java.applet.*; import java.awt.event.*;
Program 20: //Design an Applet program to handle Mouse Events. import java.awt.*; import java.applet.*; import java.awt.event.*; /* */ public
More informationA sample print out is: is is -11 key entered was: w
Lab 9 Lesson 9-2: Exercise 1, 2 and 3: Note: when you run this you may need to maximize the window. The modified buttonhandler is: private static class ButtonListener implements ActionListener public void
More informationCS153: Midterm (Winter 19)
CS153: Midterm (Winter 19) Name: Student ID: Answer all questions. State any assumptions clearly. Problem 1: (24 points; 5 minutes) Indicate whether each of the following statements is true or false: (T)
More informationG51PGP Programming Paradigms. Lecture 009 Concurrency, exceptions
G51PGP Programming Paradigms Lecture 009 Concurrency, exceptions 1 Reminder subtype polymorphism public class TestAnimals public static void main(string[] args) Animal[] animals = new Animal[6]; animals[0]
More informationThe Deadlock Problem (1)
Deadlocks The Deadlock Problem (1) A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set. Example System has 2 disk drives. P 1 and P 2
More informationUniversity of Babylon / College of Information Technology / Network Department. Operating System / Dr. Mahdi S. Almhanna & Dr. Rafah M.
Chapter 6 Methods for Handling Deadlocks Generally speaking, we can deal with the deadlock problem in one of three ways: We can use a protocol to prevent or avoid deadlocks, ensuring that the system will
More informationChapter 7 : 7: Deadlocks Silberschatz, Galvin and Gagne 2009 Operating System Concepts 8th Edition, Chapter 7: Deadlocks
Chapter 7: Deadlocks, Silberschatz, Galvin and Gagne 2009 Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance
More informationDeadlocks. Dr. Yingwu Zhu
Deadlocks Dr. Yingwu Zhu Deadlocks Synchronization is a live gun we can easily shoot ourselves in the foot Incorrect use of synchronization can block all processes You have likely been intuitively avoiding
More informationChapter 8 Threads Zindell Technologies, Ltd. Question 1: Which one statement below is true concerning the following code?
1 Chapter 8 Threads Question 1: Which one statement below is true concerning the following code? 1. class Hevron extends java.util.vector implements Runnable 2. 3. public void run(int counter) 4. 3. System.out.println("in
More informationCSC 716 Advanced Operating System Fall 2007 Exam 1. Answer all the questions. The maximum credit for each question is as shown.
CSC 716 Advanced Operating System Fall 2007 Exam 1 Answer all the questions. The maximum credit for each question is as shown. 1. (15) Multiple Choice(3 points for each): 1) Which of the following statement
More informationExercise 4: Loops, Arrays and Files
Exercise 4: Loops, Arrays and Files worth 24% of the final mark November 4, 2004 Instructions Submit your programs in a floppy disk. Deliver the disk to Michele Zito at the 12noon lecture on Tuesday November
More informationLecture 7 Deadlocks (chapter 7)
Bilkent University Department of Computer Engineering CS342 Operating Systems Lecture 7 Deadlocks (chapter 7) Dr. İbrahim Körpeoğlu http://www.cs.bilkent.edu.tr/~korpe 1 References The slides here are
More informationCOURSE 11 PROGRAMMING III OOP. JAVA LANGUAGE
COURSE 11 PROGRAMMING III OOP. JAVA LANGUAGE PREVIOUS COURSE CONTENT Input/Output Streams Text Files Byte Files RandomAcessFile Exceptions Serialization NIO COURSE CONTENT Threads Threads lifecycle Thread
More information6O03 project report. Main points for the solution. Build a combination possibility tableau. Problem: Page 5, the prime number problem
1 6O03 project report Problem: Page 5, the prime number problem Main points for the solution The problem is asking a minimum value of k with given a number of the possibility of its prime combination multinomial.
More informationProduced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar
Design Patterns MSc in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie)! Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie
More informationChapter 7: Deadlocks
Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock Chapter
More informationChapter 5 Some useful classes
Chapter 5 Some useful classes Lesson page 5-1. Numerical wrapper classes Activity 5-1-1 Wrapper-class Integer Question 1. False. A new Integer can be created, but its contents cannot be changed. Question
More informationOperating systems. Lecture 5. Deadlock: System Model. Deadlock: System Model. Process synchronization Deadlocks. Deadlock: System Model
Lecture 5 Operating systems Process synchronization Deadlocks Deadlock: System Model Computer system: Processes (program in execution); Resources (CPU, memory space, files, I/O devices, on so on). Deadlock:
More informationThe Deadlock Problem
Deadlocks The Deadlock Problem A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set. Example System has 2 disk drives. P1 and P2 each
More information