Department of Computer Science. COS 122 Operating Systems. Practical 3. Due: 22:00 PM

Size: px
Start display at page:

Download "Department of Computer Science. COS 122 Operating Systems. Practical 3. Due: 22:00 PM"

Transcription

1 Department of Computer Science COS 122 Operating Systems Practical 3 Due: 22:00 PM August 30, 2018

2 PLAGIARISM POLICY UNIVERSITY OF PRETORIA The Department of Computer Science considers plagiarism as a serious offence. Disciplinary action will be taken against students who commit plagiarism. Plagiarism includes copying someone else s work without consent, copying a friend s work (even with consent) and copying material (such as text or program code) from the Internet. Copying will not be tolerated in this course. For a formal definition of plagiarism, the student is referred to ais.up.ac.za/plagiarism/index.htm (from the main page of the University of Pretoria site, follow the Library quick link, and then click the Plagiarism link). If you have any form of question regarding this, please ask one of the lecturers, to avoid any misunderstanding. Also note that the OOP principle of code re-use does not mean that you should copy and adapt code to suit your solution.

3 Instructions In this module it is advised that you have a Virtual Machine(VM) to do all your practicals due to the nature of this course it is easy to mistakenly destroy your Operating System. For all practicals you must make use of a Linux VM. Follow the Upload and Demo instructions carefully at the end of the practical. All written answers must be in pdf format as no other formats will be marked. Only upload your source code, makefile, and supporting documents. Do not upload large, binary, or OS files. Keep your uploaded archive small. Upload your work in a zip or tar.gz file before 22:00 on the 13rd of September Bring your VM on a flash disk to your booked practical demonstration session in the week starting on the 17th of September, so you may be marked. On non-demo days, there will still be teaching assistants available in the labs to help you. Make use of a Makefile for your programs. You makefile must have these commands: # make # make run 2

4 Scenario One day you come home very chuffed with yourself because you have just bought a printer that allows you to print anything remotely. This printer also allows a number of users to combine parts of a file together to successfully print the full file. To test it out you find some ASCII art that you would like to print using your special printer. You decide to test out the feature that allows multiple users to combine a file together. This is achieved by having a client-server model set up where the server will (when requested) send a certain piece of the ASCII art to the requesting client. The Server Class The Server class is simply there to emulate a server in the client-server model/architecture and includes the following functions: Server(string filename, int threads) - This is the constructor and will read in a file specified by filename and split the content of the file into threads number of pieces and store it in an array called ascii. Keep in mind that the indexes start from 0 and not 1. Server - The destructor which deletes the dynamically allocated ascii array. getpiece(int piece) - A method which returns the piece (a string) from the ascii array specified by piece. Task 1 - Deadlock [9 Marks] This is NOT a Fitchfork task. In this task you are required to implement a number of functions in the file deadlock.cpp. This file can be downloaded from the CS website. The implementation of these functions should provide you with two deadlock situations. You will need to use threads when implementing these functions. You may use high level C++ threads OR pthreads for this purpose. You will also need to use some locking mechanism to achieve mutual exclusion between threads. The methods you need to implement are as follows: 1. printtoscreen(string toscreen) - Implement this function to deal with the race condition on stdout (i.e. printing to the screen). If multiple threads try and output to the screen concurrently, much of the text being output will collide with each other and create a line, or multiple lines, of difficult to interpret text. This is what is meant by the race condition on stdout. 2. output(string toprint) - This function writes the string toprint to a file called deadlock.txt. Before opening the file you will need to output, to the screen, the string Opening... and before writing to the file output, to the screen, the string Writing.... 3

5 3. spin(int index) - Since the printer needs the pieces of the ASCII file in the order they need to be put on the page; this function needs to ensure that a thread only sends their piece to the printer in the correct sequence (specified by the threads indexes). Thus each thread will need to wait/spin until the piece of ASCII art that they have requested from the server is to be printed. Once a thread is able to send their piece to the printer you will need to gain lock access to do so. E.g: 3 threads are being used, so thread 0 has piece 0, thread 1 has piece 1 and thread 2 has piece 2. Thread 0 Thread 1 Thread 2 Calls spin but doesn t Calls spin and waits Calls spin and waits wait Gains lock access and Still waiting Still waiting outputs to deadlock.txt Releases lock access Gains lock access and Still waiting outputs to deadlock.txt Join Released lock access Gains lock access and outputs to deadlock.txt Join Released lock access Join 4. lock(int choice) - Use any type of locking mechanism of your choice. You may use a library for this or you may implement your own locking mechanism. Allow for locking either access to the server (choice == 1) or access to the printer (choice == 2). 5. unlock(int choice) - Use any type of unlocking mechanism of your choice. You may use a library for this or you may implement your own unlocking mechanism. Allow for unlocking either access to the server (choice == 1) or access to the printer (choice == 2). 6. main(...) - You should allow for 2 command line arguments: (a) The filename where the ASCII art is stored. (b) The number of threads to use. You will need to create the number of threads specified by the second argument. Based on their index (not the thread ID) you will need to call separate functions: eventhread(int index) for an even indexed thread and oddthread(int index) for an odd indexed thread. The indexes must start at 0, not 1. Before creating each thread, sleep for a random time between 0 and 4 seconds (this will allow both deadlock scenarios to occur on different executions). Please Note: You may not edit the eventhread and oddthread functions. 4

6 Every time you execute the program the contents of the deadlock.txt file must be overwritten. The two deadlock situations that can occur are shown in the output below (please ensure that your output looks similar): (b) Deadlock scenario 2 (a) Deadlock scenario 1 Task 2 [10 Marks - 6 FF, 4 in session] This IS a Fitchfork task but your code will also be checked in your marking session. The aim of this task is to remove the deadlock from the code implemented in Task 1. You will implement this in the file mutex.cpp which can be downloaded from the CS website. You may reuse your code in the implementation of the functions from the above task. Make sure your deadlock is gone before submitting this task, since deadlocked programs will not return feedback and many such uploads can cause the server to slow down. You have to submit this task to Fitchfork and the final upload slot. Fitchfork upload slots will open on Tuesday 4 Aug at 00:00 (midnight). Things to note before completing this task: 1. Please note that there is an added line to the eventhread and oddthread functions (in the catch). Do not remove any lines from these functions or you will be penalised. Hint: you may add lines to or move lines around within these functions. 2. The lines stated above throw a new exception after catching the 500 Internal Server Error. You are required to handle this newly thrown exception and unlock successfully to avoid the newly resulting deadlock. Don t forget that after handling this exception the thread still needs to send its piece of the ASCII art to the printer so that the art can be written to the file. Please note that this new exception may 5

7 be thrown multiple times during the same execution but will not happen every time you run your file (due to the probability of throwing the 500 Internal Server Error). 3. The file that you will need to write data to should be called mutex.txt. Your output should look similar to the following: (b) Mutex File Output (printer) (a) mutex.cpp Screen Output Task 3 [14 Marks - 9 FF, 5 in session] This IS a Fitchfork task but your code will also be checked in your marking session. In this task you will be implementing the functions in the msgpass.cpp file which you can download from the CS website. You may reuse your code in the implementation of the functions from the above task. Make sure your deadlock is gone before submitting this task, since deadlocked programs will not return feedback and many such uploads can cause the server to slow down. You have to submit this task to Fitchfork and the final upload slot. Fitchfork upload slots will open on Tuesday 4 Aug at 00:00 (midnight). This task still has the same scenario where each client can send their piece to the printer, however this time you decide to use a message queue to emulate message passing between the clients/threads. The idea is that after each client/thread has requested the 6

8 piece from the server, that piece, along with the client/thread index, will be sent (in this case by pushing them onto the message queue) to a single client/thread who is acting as a mediator for the print job. Once all pieces have been pushed onto the queue, the mediator client/thread will receive (in this case by popping the pieces off the message queue individually) all the messages and send them to the printer in reverse order. The Message struct This struct has been given to you in the msgpass.cpp file. The elements are as follows: 1. string payload - This is a string that will contain the piece of the ASCII art to print. 2. uint t ind - This is the thread index of the thread that is sending this message. The MsgPass Class This class has been implemented for you, however mutual exclusion has not been added for access to the message queue. Notice that there is an instance (called m) of this class already created for you in the file. Implement: You must implement mutual exclusion within this class for reading from and writing to the queue. Please keep the scenario above in mind when implementing this. The functions in this class are as follows: 1. MsgPass(uint upper b) - The constructor simply initialises an upper bound for the queue size. 2. void send(struct Message m) - This adds the message m to the message queue. 3. struct Message recv() - This removes and returns the first message in the message queue. 4. bool isfull() - Uses the upper bound specified in the constructor to check whether the number of messages in the queue has reached the upper bound and returns true if it has and false otherwise. 5. uint getsize() - returns the number of messages on the queue. 6. bool empty() - returns true if the queue is empty and false otherwise. Implementation You must implement all the empty functions in the msgpass.cpp file. You may reuse code from the previous task to complete them. Realise that the eventhread, oddthread 7

9 and spin functions have been removed and two new functions have been added. The two functions are as follows and either all or some of the code in these functions need to be implemented: 1. passalong(int index) - This function requests the piece of the ASCII art from the server and constructs the message (using the Message struct) to be sent and placed on the message queue. You must simply create a new message, initialise the variables of the message with the piece and the thread index. The send has been given to you. 2. getandwrite() - This function is called from the passalong function (by the mediator thread) and should receive all the messages from the message queue and print them in reverse order based on t ind. Remember: The mediator thread (to print the final result) must be called after all threads have finished adding their messages to the message queue. Your output should look similar to the following: (b) MsgPass File Output (printer) (a) msgpass.cpp Screen Output Important! You have to use the specified C++ program names. You have to create and upload a makefile. You need to upload task2 and task3 to the corresponding Fitchfork upload slots. 8

10 Task 4 - Theory on Deadlock and Mutual Exclusion [8 Marks] In this task you are required to answer the following questions in a summarized form. You should be able to answer these questions in person during the demo session as well. (a) In Task 1 explain the two forms of deadlock that occurred and explain why they occurred? (b) Assume that when implementing the tasks above the c++ mutex library was used ( Referring to the scenario throughout this practical, what is the main potential problem that can, although rarely, occur when using this mutex library? (c) In your implementation of mutual exclusion in Task 2 how did you stop the deadlocks in Task 1 from occurring again? (d) In Task 3, why was it important to lock access to the message queue? (e) With reference to the Readers/Writers problem in the book, why would you say that the message queue implementation in Task 3 is not necessarily seen as the typical Readers/Writers problem? (f) Assuming there was no locking mechanism for reading from the queue, why would it be a problem if multiple clients/threads were to concurrently receive messages from the message queue in Task 3? 9

11 Upload Instructions As it would be impractical to upload your Virtual Machine to the CS website for the practicals, you are required to submit your code and answers to the written questions: Upload all your tasks in a zip or tar.gz file to the Practical 3 assignment slot on the COS 122 course website before 22:00 on Monday 13 September No late submissions will be accepted. Upload your Fitchfork tasks in a zip or tar.gz file to the corresponding Prac 3 task slots on the assignments website before 22:00 on Monday 13 September No late submissions will be accepted. Please make sure that you do this as there have been a number of queries saying that they have not uploaded to Fitchfork as well as the normal upload slot. You have to demo what you uploaded to the COS 122 course website. All written answers must be in either txt or pdf format no other formats will be marked. Every file you submit should contain your name, surname, and student number at the top of the file in comments. Only upload your source code, makefiles, and supporting documents. upload large, binary, or OS files. Keep your uploaded archive small. Do not Failure to upload your work will result in 0 marks being awarded for your practical. Demo Instructions At the demo, we will check your uploaded work. Only students who have uploaded on time will be allowed to demo. You may only demo during the slot where you are booked. You should be able to demo the practical within Virtual Box. This practical must be marked by a tutor or teaching assistant during your booked practical demonstration sessions. You have to be there at the start of the session until you get marked. If you come just before the session ends you will not get marked. You have a limited time to demo approximately 8 minutes. Please ensure that your VM is running before you get marked to speed up the process. If your program doesn t compile due to syntax errors you will get 0 marks. If your program receives a runtime error you will lose marks. If your program still has deadlock for Task 2 and/or Task 3 you will lose marks. 10

12 You have to be prepared to answer any question(s) the teaching assistant or tutor may ask you. You should not have to waste time looking for the answer. Make sure that you sign the attendance register for the session and ensure that the teaching assistant has entered your mark on the mark sheet correctly. Failure to demo your tasks will result in 0 marks being awarded for those tasks. Total: [41] 11

Department of Computer Science University of Pretoria. Introduction to Computer Science COS 151

Department of Computer Science University of Pretoria. Introduction to Computer Science COS 151 Department of Computer Science University of Pretoria Introduction to Computer Science COS 151 Practical 1 16 February 2018 1 Plagiarism Policy The Department of Computer Science considers plagiarism as

More information

Operating Systems, Assignment 2 Threads and Synchronization

Operating Systems, Assignment 2 Threads and Synchronization Operating Systems, Assignment 2 Threads and Synchronization Responsible TA's: Zohar and Matan Assignment overview The assignment consists of the following parts: 1) Kernel-level threads package 2) Synchronization

More information

Operating Systems (234123) Spring (Homework 3 Wet) Homework 3 Wet

Operating Systems (234123) Spring (Homework 3 Wet) Homework 3 Wet Due date: Monday, 4/06/2012 12:30 noon Teaching assistants in charge: Operating Systems (234123) Spring-2012 Homework 3 Wet Anastasia Braginsky All emails regarding this assignment should be sent only

More information

l Determine if a number is odd or even l Determine if a number/character is in a range - 1 to 10 (inclusive) - between a and z (inclusive)

l Determine if a number is odd or even l Determine if a number/character is in a range - 1 to 10 (inclusive) - between a and z (inclusive) Final Exam Exercises Chapters 1-7 + 11 Write C++ code to: l Determine if a number is odd or even CS 2308 Fall 2016 Jill Seaman l Determine if a number/character is in a range - 1 to 10 (inclusive) - between

More information

CS2 Practical 2 CS2Ah

CS2 Practical 2 CS2Ah CS2 Practical 2 Finite automata This practical is based on material in the language processing thread. The practical is made up of two parts. Part A consists of four paper and pencil exercises, designed

More information

: Distributed Systems Principles and Paradigms Assignment 1 Multithreaded Dictionary Server

: Distributed Systems Principles and Paradigms Assignment 1 Multithreaded Dictionary Server 433 652: Distributed Systems Principles and Paradigms Assignment 1 Multithreaded Dictionary Server Problem Description Using a client server architecture, design and implement a multi threaded server that

More information

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2004

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2004 CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2004 Lecture 9: Readers-Writers and Language Support for Synchronization 9.1.2 Constraints 1. Readers can access database

More information

Student Website / Portal Guidelines

Student Website / Portal Guidelines Student Website / Portal Guidelines Contents INTRODUCTION...3 CONNECTING TO THE BRADFIELD GROUP WEBSITE...3 STUDENTS HOMEPAGE...4 STUDENT ASSIGNMENTS...4 DOWNLOAD ASSIGNMENT BRIEF...5 REQUEST AN EXTENSION

More information

CS 202, Fall 2017 Homework #4 Balanced Search Trees and Hashing Due Date: December 18, 2017

CS 202, Fall 2017 Homework #4 Balanced Search Trees and Hashing Due Date: December 18, 2017 CS 202, Fall 2017 Homework #4 Balanced Search Trees and Hashing Due Date: December 18, 2017 Important Notes Please do not start the assignment before reading these notes. Before 23:55, December 18, upload

More information

You must include this cover sheet. Either type up the assignment using theory4.tex, or print out this PDF.

You must include this cover sheet. Either type up the assignment using theory4.tex, or print out this PDF. 15-122 Assignment 4 Page 1 of 12 15-122 : Principles of Imperative Computation Fall 2012 Assignment 4 (Theory Part) Due: Thursday, October 18, 2012 at the beginning of lecture Name: Andrew ID: Recitation:

More information

SYNCHRONIZATION M O D E R N O P E R A T I N G S Y S T E M S R E A D 2. 3 E X C E P T A N D S P R I N G 2018

SYNCHRONIZATION M O D E R N O P E R A T I N G S Y S T E M S R E A D 2. 3 E X C E P T A N D S P R I N G 2018 SYNCHRONIZATION M O D E R N O P E R A T I N G S Y S T E M S R E A D 2. 3 E X C E P T 2. 3. 8 A N D 2. 3. 1 0 S P R I N G 2018 INTER-PROCESS COMMUNICATION 1. How a process pass information to another process

More information

CSCI-1200 Data Structures Fall 2009 Lecture 25 Concurrency & Asynchronous Computing

CSCI-1200 Data Structures Fall 2009 Lecture 25 Concurrency & Asynchronous Computing CSCI-1200 Data Structures Fall 2009 Lecture 25 Concurrency & Asynchronous Computing Final Exam General Information The final exam will be held Monday, Dec 21st, 2009, 11:30am-2:30pm, DCC 308. A makeup

More information

Synchronising Threads

Synchronising Threads Synchronising Threads David Chisnall March 1, 2011 First Rule for Maintainable Concurrent Code No data may be both mutable and aliased Harder Problems Data is shared and mutable Access to it must be protected

More information

Deadlock and Monitors. CS439: Principles of Computer Systems September 24, 2018

Deadlock and Monitors. CS439: Principles of Computer Systems September 24, 2018 Deadlock and Monitors CS439: Principles of Computer Systems September 24, 2018 Bringing It All Together Processes Abstraction for protection Define address space Threads Share (and communicate) through

More information

Week 8 Locking, Linked Lists, Scheduling Algorithms. Classes COP4610 / CGS5765 Florida State University

Week 8 Locking, Linked Lists, Scheduling Algorithms. Classes COP4610 / CGS5765 Florida State University Week 8 Locking, Linked Lists, Scheduling Algorithms Classes COP4610 / CGS5765 Florida State University 1 Concurrency Aspects of Project 2 Synchronizing access to request queue(s) Multiple producers may

More information

COMP90015: Distributed Systems Assignment 1 Multi-threaded Dictionary Server (15 marks)

COMP90015: Distributed Systems Assignment 1 Multi-threaded Dictionary Server (15 marks) COMP90015: Distributed Systems Assignment 1 Multi-threaded Dictionary Server (15 marks) Problem Description Using a client-server architecture, design and implement a multi-threaded server that allows

More information

Agents Implementation for C++ MASS Library

Agents Implementation for C++ MASS Library Agents Implementation for C++ MASS Library CSS 497 Spring 2014 Term Report Chris Rouse Contents Work Summary... 2 Initial Goals... 2 Current Work Progress... 3 Detailed Specification... 3 Agent Diagram...

More information

CS 241 Honors Concurrent Data Structures

CS 241 Honors Concurrent Data Structures CS 241 Honors Concurrent Data Structures Bhuvan Venkatesh University of Illinois Urbana Champaign March 27, 2018 CS 241 Course Staff (UIUC) Lock Free Data Structures March 27, 2018 1 / 43 What to go over

More information

CSE 153 Design of Operating Systems

CSE 153 Design of Operating Systems CSE 153 Design of Operating Systems Winter 19 Lecture 7/8: Synchronization (1) Administrivia How is Lab going? Be prepared with questions for this weeks Lab My impression from TAs is that you are on track

More information

Lecture 5: Synchronization w/locks

Lecture 5: Synchronization w/locks Lecture 5: Synchronization w/locks CSE 120: Principles of Operating Systems Alex C. Snoeren Lab 1 Due 10/19 Threads Are Made to Share Global variables and static objects are shared Stored in the static

More information

IV. Process Synchronisation

IV. Process Synchronisation IV. Process Synchronisation Operating Systems Stefan Klinger Database & Information Systems Group University of Konstanz Summer Term 2009 Background Multiprogramming Multiple processes are executed asynchronously.

More information

! Determine if a number is odd or even. ! Determine if a number/character is in a range. - 1 to 10 (inclusive) - between a and z (inclusive)

! Determine if a number is odd or even. ! Determine if a number/character is in a range. - 1 to 10 (inclusive) - between a and z (inclusive) Final Exam Exercises CS 2308 Spring 2014 Jill Seaman Chapters 1-7 + 11 Write C++ code to: Determine if a number is odd or even Determine if a number/character is in a range - 1 to 10 (inclusive) - between

More information

Synchronization. CS 475, Spring 2018 Concurrent & Distributed Systems

Synchronization. CS 475, Spring 2018 Concurrent & Distributed Systems Synchronization CS 475, Spring 2018 Concurrent & Distributed Systems Review: Threads: Memory View code heap data files code heap data files stack stack stack stack m1 m1 a1 b1 m2 m2 a2 b2 m3 m3 a3 m4 m4

More information

CS 202, Fall 2017 Homework #3 Heaps and AVL Trees

CS 202, Fall 2017 Homework #3 Heaps and AVL Trees CS 202, Fall 2017 Homework #3 Heaps and AVL Trees Due Date: November 27, 2017 Important Notes Please do not start the assignment before reading these notes. Before 23:55, November 27, upload your solutions

More information

CS 105, Spring 2015 Ring Buffer

CS 105, Spring 2015 Ring Buffer CS 105, Spring 2015 Ring Buffer March 10, 2015 1 Introduction A ring buffer, also called a circular buffer, is a common method of sharing information between a producer and a consumer. In class, we have

More information

CS 153 Design of Operating Systems Winter 2016

CS 153 Design of Operating Systems Winter 2016 CS 153 Design of Operating Systems Winter 2016 Lecture 9: Semaphores and Monitors Some slides from Matt Welsh Summarize Where We Are Goal: Use mutual exclusion to protect critical sections of code that

More information

ASSIGNMENT TWO: PHONE BOOK

ASSIGNMENT TWO: PHONE BOOK ASSIGNMENT TWO: PHONE BOOK ADVANCED PROGRAMMING TECHNIQUES SEMESTER 1, 2017 SUMMARY In this assignment, you will use your C programming skills to create a phone book. The phone book loads its entries from

More information

CS3114 (Fall 2013) PROGRAMMING ASSIGNMENT #2 Due Tuesday, October 11:00 PM for 100 points Due Monday, October 11:00 PM for 10 point bonus

CS3114 (Fall 2013) PROGRAMMING ASSIGNMENT #2 Due Tuesday, October 11:00 PM for 100 points Due Monday, October 11:00 PM for 10 point bonus CS3114 (Fall 2013) PROGRAMMING ASSIGNMENT #2 Due Tuesday, October 15 @ 11:00 PM for 100 points Due Monday, October 14 @ 11:00 PM for 10 point bonus Updated: 10/10/2013 Assignment: This project continues

More information

CSE Traditional Operating Systems deal with typical system software designed to be:

CSE Traditional Operating Systems deal with typical system software designed to be: CSE 6431 Traditional Operating Systems deal with typical system software designed to be: general purpose running on single processor machines Advanced Operating Systems are designed for either a special

More information

OpenMP and more Deadlock 2/16/18

OpenMP and more Deadlock 2/16/18 OpenMP and more Deadlock 2/16/18 Administrivia HW due Tuesday Cache simulator (direct-mapped and FIFO) Steps to using threads for parallelism Move code for thread into a function Create a struct to hold

More information

COMP6771 Advanced C++ Programming

COMP6771 Advanced C++ Programming 1.... COMP6771 Advanced C++ Programming Week 9 Multithreading 2016 www.cse.unsw.edu.au/ cs6771 .... Single Threaded Programs All programs so far this semester have been single threaded They have a single

More information

Lecture 9: Midterm Review

Lecture 9: Midterm Review Project 1 Due at Midnight Lecture 9: Midterm Review CSE 120: Principles of Operating Systems Alex C. Snoeren Midterm Everything we ve covered is fair game Readings, lectures, homework, and Nachos Yes,

More information

Recitation 14: Proxy Lab Part 2

Recitation 14: Proxy Lab Part 2 Recitation 14: Proxy Lab Part 2 Instructor: TA(s) 1 Outline Proxylab Threading Threads and Synchronization PXYDRIVE Demo 2 ProxyLab Checkpoint is worth 1%, due Thursday, Nov. 29 th Final is worth 7%, due

More information

C++11 threads -- a simpler interface than pthreads Examples largely taken from https://latedev.wordpress.com/ 013/02/24/investigating-c11-threads/

C++11 threads -- a simpler interface than pthreads Examples largely taken from https://latedev.wordpress.com/ 013/02/24/investigating-c11-threads/ C++11 threads -- a simpler interface than pthreads Examples largely taken from https://latedev.wordpress.com/ 013/02/24/investigating-c11-threads/ #include #include using namespace

More information

Precept 2: Non-preemptive Scheduler. COS 318: Fall 2018

Precept 2: Non-preemptive Scheduler. COS 318: Fall 2018 Precept 2: Non-preemptive Scheduler COS 318: Fall 2018 Project 2 Schedule Precept: Monday 10/01, 7:30pm (You are here) Design Review: Monday 10/08, 3-7pm Due: Sunday 10/14, 11:55pm Project 2 Overview Goal:

More information

COMP6771 Advanced C++ Programming

COMP6771 Advanced C++ Programming 1. COMP6771 Advanced C++ Programming Week 9 Multithreading (continued) 2016 www.cse.unsw.edu.au/ cs6771 2. So Far Program Workflows: Sequential, Parallel, Embarrassingly Parallel Memory: Shared Memory,

More information

Midterm on next week Tuesday May 4. CS 361 Concurrent programming Drexel University Fall 2004 Lecture 9

Midterm on next week Tuesday May 4. CS 361 Concurrent programming Drexel University Fall 2004 Lecture 9 CS 361 Concurrent programming Drexel University Fall 2004 Lecture 9 Bruce Char and Vera Zaychik. All rights reserved by the author. Permission is given to students enrolled in CS361 Fall 2004 to reproduce

More information

Pre-lab #2 tutorial. ECE 254 Operating Systems and Systems Programming. May 24, 2012

Pre-lab #2 tutorial. ECE 254 Operating Systems and Systems Programming. May 24, 2012 Pre-lab #2 tutorial ECE 254 Operating Systems and Systems Programming May 24, 2012 Content Concurrency Concurrent Programming Thread vs. Process POSIX Threads Synchronization and Critical Sections Mutexes

More information

Concurrency, Thread. Dongkun Shin, SKKU

Concurrency, Thread. Dongkun Shin, SKKU Concurrency, Thread 1 Thread Classic view a single point of execution within a program a single PC where instructions are being fetched from and executed), Multi-threaded program Has more than one point

More information

CS11 Java. Fall Lecture 7

CS11 Java. Fall Lecture 7 CS11 Java Fall 2006-2007 Lecture 7 Today s Topics All about Java Threads Some Lab 7 tips Java Threading Recap A program can use multiple threads to do several things at once A thread can have local (non-shared)

More information

CS 450 Exam 2 Mon. 4/11/2016

CS 450 Exam 2 Mon. 4/11/2016 CS 450 Exam 2 Mon. 4/11/2016 Name: Rules and Hints You may use one handwritten 8.5 11 cheat sheet (front and back). This is the only additional resource you may consult during this exam. No calculators.

More information

How to Get Writing Tutoring Using WCONLINE

How to Get Writing Tutoring Using WCONLINE 1 How to Get Writing Tutoring Using WCONLINE The first step is creating a user name and password. The first time you go to https://nsuok.mywconline.com, you will be greeted with the welcome page. Since

More information

CS2 Practical 1 CS2A 22/09/2004

CS2 Practical 1 CS2A 22/09/2004 CS2 Practical 1 Basic Java Programming The purpose of this practical is to re-enforce your Java programming abilities. The practical is based on material covered in CS1. It consists of ten simple programming

More information

A Brief Review for the Final. Final Examination

A Brief Review for the Final. Final Examination A Brief Review for the Final These slides are created by Dr. Huang of George Mason University. Students registered in Dr. Huang s courses at GMU can make a single machine readable copy and print a single

More information

CS-537: Midterm Exam (Spring 2001)

CS-537: Midterm Exam (Spring 2001) CS-537: Midterm Exam (Spring 2001) Please Read All Questions Carefully! There are seven (7) total numbered pages Name: 1 Grading Page Points Total Possible Part I: Short Answers (12 5) 60 Part II: Long

More information

You must pass the final exam to pass the course.

You must pass the final exam to pass the course. Computer Science Technology Department Houston Community College System Department Website: http://csci.hccs.cc.tx.us CRN: 46876 978-1-4239-0146-4 1-4239-0146-0 Semester: Fall 2010 Campus and Room: Stafford

More information

CPS 110 Midterm. Spring 2011

CPS 110 Midterm. Spring 2011 CPS 110 Midterm Spring 2011 Ola! Greetings from Puerto Rico, where the air is warm and salty and the mojitos are cold and sweet. Please answer all questions for a total of 200 points. Keep it clear and

More information

Introduction to Programming II Winter, 2015 Assignment 5 (Saturday, April 4, 2015: 23:59:59)

Introduction to Programming II Winter, 2015 Assignment 5 (Saturday, April 4, 2015: 23:59:59) 60-4 Introduction to Programming II Winter, 205 Assignment 5 (Saturday, April 4, 205: 2:59:59) This is a lengthy assignment description. Take time to read it carefully and thoroughly. Dynamic Linked Lists

More information

CMSC421: Principles of Operating Systems

CMSC421: Principles of Operating Systems CMSC421: Principles of Operating Systems Nilanjan Banerjee Assistant Professor, University of Maryland Baltimore County nilanb@umbc.edu http://www.csee.umbc.edu/~nilanb/teaching/421/ Principles of Operating

More information

COMP 3430 Robert Guderian

COMP 3430 Robert Guderian Operating Systems COMP 3430 Robert Guderian file:///users/robg/dropbox/teaching/3430-2018/slides/04_threads/index.html?print-pdf#/ 1/58 1 Threads Last week: Processes This week: Lesser processes! file:///users/robg/dropbox/teaching/3430-2018/slides/04_threads/index.html?print-pdf#/

More information

Programming Standards: You must conform to good programming/documentation standards. Some specifics:

Programming Standards: You must conform to good programming/documentation standards. Some specifics: CS3114 (Spring 2011) PROGRAMMING ASSIGNMENT #3 Due Thursday, April 7 @ 11:00 PM for 100 points Early bonus date: Wednesday, April 6 @ 11:00 PM for a 10 point bonus Initial Schedule due Thursday, March

More information

sample exam Concurrent Programming tda383/dit390 Sample exam March 2016 Time:?? Place: Johanneberg

sample exam Concurrent Programming tda383/dit390 Sample exam March 2016 Time:?? Place: Johanneberg sample exam Concurrent Programming tda383/dit390 Sample exam March 2016 Time:?? Place: Johanneberg Responsible Michał Pałka 0707966066 Result Available no later than?-?-2016 Aids Max 2 books and max 4

More information

OPERATING SYSTEMS ASSIGNMENT 2 SIGNALS, USER LEVEL THREADS AND SYNCHRONIZATION

OPERATING SYSTEMS ASSIGNMENT 2 SIGNALS, USER LEVEL THREADS AND SYNCHRONIZATION OPERATING SYSTEMS ASSIGNMENT 2 SIGNALS, USER LEVEL THREADS AND SYNCHRONIZATION Responsible TAs: Vadim Levit & Benny Lutati Introduction In this assignment we will extend xv6 to support a simple signal

More information

OPERATING SYSTEMS - ASSIGNMENT 2 SYNCHRONIZATION & THREADS

OPERATING SYSTEMS - ASSIGNMENT 2 SYNCHRONIZATION & THREADS OPERATING SYSTEMS - ASSIGNMENT 2 SYNCHRONIZATION & THREADS Introduction In this assignment we will add synchronization tools\methods to the xv6 kernel. We start with a simple binary semaphore and then

More information

CS 211 Programming Practicum Fall 2018

CS 211 Programming Practicum Fall 2018 Due: Wednesday, 11/7/18 at 11:59 pm Infix Expression Evaluator Programming Project 5 For this lab, write a C++ program that will evaluate an infix expression. The algorithm REQUIRED for this program will

More information

Fine-grained synchronization & lock-free programming

Fine-grained synchronization & lock-free programming Lecture 17: Fine-grained synchronization & lock-free programming Parallel Computer Architecture and Programming CMU 15-418/15-618, Spring 2016 Tunes Minnie the Moocher Robbie Williams (Swings Both Ways)

More information

C++ Threading. Tim Bailey

C++ Threading. Tim Bailey C++ Threading Introduction Very basic introduction to threads I do not discuss a thread API Easy to learn Use, eg., Boost.threads Standard thread API will be available soon The thread API is too low-level

More information

Operating Systems EDA092, DIT 400 Exam

Operating Systems EDA092, DIT 400 Exam Chalmers University of Technology and Gothenburg University Operating Systems EDA092, DIT 400 Exam 2015-04-14 Date, Time, Place: Tuesday 2015/04/14, 14:00 18:00, Väg och vatten -salar Course Responsible:

More information

Operating Systems Synchronization and Signals

Operating Systems Synchronization and Signals OS162: Assignment 2 Operating Systems Synchronization and Signals TAs in charge Vadim Levit levitv@post.bgu.ac.il Benny Lutati bennyl@post.bgu.ac.il Due Date: 30.04.2016 1 Introduction The assignment main

More information

Operating Systems. Lecture 4 - Concurrency and Synchronization. Master of Computer Science PUF - Hồ Chí Minh 2016/2017

Operating Systems. Lecture 4 - Concurrency and Synchronization. Master of Computer Science PUF - Hồ Chí Minh 2016/2017 Operating Systems Lecture 4 - Concurrency and Synchronization Adrien Krähenbühl Master of Computer Science PUF - Hồ Chí Minh 2016/2017 Mutual exclusion Hardware solutions Semaphores IPC: Message passing

More information

Pipelined RISC-V Processors

Pipelined RISC-V Processors Due date: Tuesday November 20th 11:59:59pm EST Getting started: To create your initial Lab 7 repository, please visit the repository creation page at https://6004.mit.edu/web/fall18/user/labs/lab7. Once

More information

Discussion CSE 224. Week 4

Discussion CSE 224. Week 4 Discussion CSE 224 Week 4 Midterm The midterm will cover - 1. Topics discussed in lecture 2. Research papers from the homeworks 3. Textbook readings from Unit 1 and Unit 2 HW 3&4 Clarifications 1. The

More information

CS 118 Project Phase 2 P2P Networking

CS 118 Project Phase 2 P2P Networking CS 118 Project Phase 2 P2P Networking Due Monday, March 15 th at 11:59pm Boelter Hall 4428, Box D3/C4 and via Electronic Submission Overview In this phase you will extend your work from Phase 1 to create

More information

Background. The Critical-Section Problem Synchronisation Hardware Inefficient Spinning Semaphores Semaphore Examples Scheduling.

Background. The Critical-Section Problem Synchronisation Hardware Inefficient Spinning Semaphores Semaphore Examples Scheduling. Background The Critical-Section Problem Background Race Conditions Solution Criteria to Critical-Section Problem Peterson s (Software) Solution Concurrent access to shared data may result in data inconsistency

More information

COMP 346 Winter 2019 Programming Assignment 2

COMP 346 Winter 2019 Programming Assignment 2 COMP 346 Winter 2019 Programming Assignment 2 Due: 11:59 PM March 1 st, 2019 Mutual Exclusion and Barrier Synchronization 1. Objectives The objective of this assignment is to allow you to learn how to

More information

EECE.4810/EECE.5730: Operating Systems Spring 2017 Homework 2 Solution

EECE.4810/EECE.5730: Operating Systems Spring 2017 Homework 2 Solution 1. (15 points) A system with two dual-core processors has four processors available for scheduling. A CPU-intensive application (e.g., a program that spends most of its time on computation, not I/O or

More information

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 8: Semaphores, Monitors, & Condition Variables

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 8: Semaphores, Monitors, & Condition Variables CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2004 Lecture 8: Semaphores, Monitors, & Condition Variables 8.0 Main Points: Definition of semaphores Example of use

More information

JAVA and J2EE UNIT - 4 Multithreaded Programming And Event Handling

JAVA 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 information

Object Oriented Programming COP3330 / CGS5409

Object Oriented Programming COP3330 / CGS5409 Object Oriented Programming COP3330 / CGS5409 Intro to Data Structures Vectors Linked Lists Queues Stacks C++ has some built-in methods of storing compound data in useful ways, like arrays and structs.

More information

5COS005W Coursework 2 (Semester 2)

5COS005W Coursework 2 (Semester 2) University of Westminster Department of Computer Science 5COS005W Coursework 2 (Semester 2) Module leader Dr D. Dracopoulos Unit Coursework 2 Weighting: 50% Qualifying mark 30% Description Learning Outcomes

More information

Tips from the experts: How to waste a lot of time on this assignment

Tips from the experts: How to waste a lot of time on this assignment Com S 227 Spring 2018 Assignment 1 100 points Due Date: Friday, September 14, 11:59 pm (midnight) Late deadline (25% penalty): Monday, September 17, 11:59 pm General information This assignment is to be

More information

This is an individual assignment and carries 100% of the final CPS 1000 grade.

This is an individual assignment and carries 100% of the final CPS 1000 grade. CPS 1000 Assignment This is an individual assignment and carries 100% of the final CPS 1000 grade. Important instructions (read carefully and thoroughly): The firm submission deadline is Friday 5 th February

More information

Lab 4: Tracery Recursion in C with Linked Lists

Lab 4: Tracery Recursion in C with Linked Lists Lab 4: Tracery Recursion in C with Linked Lists For this lab we will be building on our previous lab at the end of the previous lab you should have had: #include #include char * make_string_from

More information

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017 CS 471 Operating Systems Yue Cheng George Mason University Fall 2017 1 Review: Sync Terminology Worksheet 2 Review: Semaphores 3 Semaphores o Motivation: Avoid busy waiting by blocking a process execution

More information

Data Structure and Algorithm Homework #3 Due: 1:20pm, Thursday, May 16, 2017 TA === Homework submission instructions ===

Data Structure and Algorithm Homework #3 Due: 1:20pm, Thursday, May 16, 2017 TA   === Homework submission instructions === Data Structure and Algorithm Homework #3 Due: 1:20pm, Thursday, May 16, 2017 TA email: dsa1@csie.ntu.edu.tw === Homework submission instructions === For Problem 1-3, please put all your solutions in a

More information

Concurrency: Signaling and Condition Variables

Concurrency: Signaling and Condition Variables Concurrency: Signaling and Condition Variables Questions Answered in this Lecture: How do we make fair locks perform better? How do we notify threads of that some condition has been met? Hale CS450 Thanks

More information

ASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists

ASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists ASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists COMP-202B, Winter 2009, All Sections Due: Tuesday, April 14, 2009 (23:55) You MUST do this assignment individually and, unless otherwise

More information

Notes to Instructors Concerning the BLITZ Projects

Notes to Instructors Concerning the BLITZ Projects Overview Notes to Instructors Concerning the BLITZ Projects Harry H. Porter III, Ph.D. Department of Computer Science Portland State University April 14, 2006 Revised: September 17, 2007 The BLITZ System

More information

Synchronization Principles

Synchronization Principles Synchronization Principles Gordon College Stephen Brinton The Problem with Concurrency Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms

More information

UCD School of Information and Library Studies. IS30020: Web Publishing

UCD School of Information and Library Studies. IS30020: Web Publishing UCD School of Information and Library Studies IS30020: Web Publishing Module Coordinator: Dr Judith Wusteman Office: SILS 110, Email: judith.wusteman@ucd.ie, Tel: 716 7612 Office hour Semester 1 (Sept

More information

CROWDMARK. Examination Midterm. Spring 2017 CS 350. Closed Book. Page 1 of 30. University of Waterloo CS350 Midterm Examination.

CROWDMARK. Examination Midterm. Spring 2017 CS 350. Closed Book. Page 1 of 30. University of Waterloo CS350 Midterm Examination. Times: Thursday 2017-06-22 at 19:00 to 20:50 (7 to 8:50PM) Duration: 1 hour 50 minutes (110 minutes) Exam ID: 3520593 Please print in pen: Waterloo Student ID Number: WatIAM/Quest Login Userid: Sections:

More information

CPSC 221: Algorithms and Data Structures Lecture #1: Stacks and Queues

CPSC 221: Algorithms and Data Structures Lecture #1: Stacks and Queues CPSC 221: Algorithms and Data Structures Lecture #1: Stacks and Queues Alan J. Hu (Slides borrowed from Steve Wolfman) Be sure to check course webpage! http://www.ugrad.cs.ubc.ca/~cs221 1 Lab 1 is available.

More information

COMP 3500 Introduction to Operating Systems Project 5 Virtual Memory Manager

COMP 3500 Introduction to Operating Systems Project 5 Virtual Memory Manager COMP 3500 Introduction to Operating Systems Project 5 Virtual Memory Manager Points Possible: 100 Submission via Canvas No collaboration among groups. Students in one group should NOT share any project

More information

CS Final Exam Review Suggestions

CS Final Exam Review Suggestions CS 325 - Final Exam Review Suggestions p. 1 last modified: 2017-12-06 CS 325 - Final Exam Review Suggestions Based on suggestions from Prof. Deb Pires from UCLA: Because of the research-supported learning

More information

Operating Systems ECE344

Operating Systems ECE344 Operating Systems ECE344 Ding Yuan Announcement & Reminder Lab 0 mark posted on Piazza Great job! One problem: compilation error I fixed some for you this time, but won t do it next time Make sure you

More information

CS140 Operating Systems and Systems Programming Midterm Exam

CS140 Operating Systems and Systems Programming Midterm Exam CS140 Operating Systems and Systems Programming Midterm Exam October 31 st, 2003 (Total time = 50 minutes, Total Points = 50) Name: (please print) In recognition of and in the spirit of the Stanford University

More information

15-213/18-213/15-513, Fall 2017 C Programming Lab: Assessing Your C Programming Skills

15-213/18-213/15-513, Fall 2017 C Programming Lab: Assessing Your C Programming Skills 15-213/18-213/15-513, Fall 2017 C Programming Lab: Assessing Your C Programming Skills 1 Logistics Assigned: Tues., Aug. 29, 2017 Due: Thurs., Sept. 7, 11:59 pm Last possible hand in: Tues., Sept. 7, 11:59

More information

Lab 1: Introduction to Java

Lab 1: Introduction to Java Lab 1: Introduction to Java Welcome to the first CS15 lab! In the reading, we went over objects, methods, parameters and how to put all of these things together into Java classes. It's perfectly okay if

More information

CSE 451 Midterm 1. Name:

CSE 451 Midterm 1. Name: CSE 451 Midterm 1 Name: 1. [2 points] Imagine that a new CPU were built that contained multiple, complete sets of registers each set contains a PC plus all the other registers available to user programs.

More information

CS 105, Spring 2007 Ring Buffer

CS 105, Spring 2007 Ring Buffer CS 105, Spring 2007 Ring Buffer April 11, 2007 1 Introduction A ring buffer, also called a circular buffer, is a common method of sharing information between a producer and a consumer. In class, we have

More information

CSC209. Software Tools and Systems Programming. https://mcs.utm.utoronto.ca/~209

CSC209. Software Tools and Systems Programming. https://mcs.utm.utoronto.ca/~209 CSC209 Software Tools and Systems Programming https://mcs.utm.utoronto.ca/~209 What is this Course About? Software Tools Using them Building them Systems Programming Quirks of C The file system System

More information

FIT3056 Secure and trusted software systems. Unit Guide. Semester 2, 2010

FIT3056 Secure and trusted software systems. Unit Guide. Semester 2, 2010 FIT3056 Secure and trusted software systems Unit Guide Semester 2, 2010 The information contained in this unit guide is correct at time of publication. The University has the right to change any of the

More information

Inheritance and Interfaces

Inheritance and Interfaces Inheritance and Interfaces Object Orientated Programming in Java Benjamin Kenwright Outline Review What is Inheritance? Why we need Inheritance? Syntax, Formatting,.. What is an Interface? Today s Practical

More information

CSL373: Lecture 5 Deadlocks (no process runnable) + Scheduling (> 1 process runnable)

CSL373: Lecture 5 Deadlocks (no process runnable) + Scheduling (> 1 process runnable) CSL373: Lecture 5 Deadlocks (no process runnable) + Scheduling (> 1 process runnable) Past & Present Have looked at two constraints: Mutual exclusion constraint between two events is a requirement that

More information

Comp 104: Operating Systems Concepts

Comp 104: Operating Systems Concepts Comp 104: Operating Systems Concepts Prof. Paul E. Dunne. Department of Computer Science, University of Liverpool. Comp 104: Operating Systems Concepts Introduction 1 2 Today Admin and module info Introduction

More information

Programming Languages ML Programming Project Due 9/28/2001, 5:00 p.m.

Programming Languages ML Programming Project Due 9/28/2001, 5:00 p.m. Programming Languages ML Programming Project Due 9/28/2001, 5:00 p.m. Functional Suite Instead of writing a single ML program, you are going to write a suite of ML functions to complete various tasks.

More information

CSC209 Review. Yeah! We made it!

CSC209 Review. Yeah! We made it! CSC209 Review Yeah! We made it! 1 CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files 2 ... and C programming... C basic syntax functions

More information

CS 318 Principles of Operating Systems

CS 318 Principles of Operating Systems CS 318 Principles of Operating Systems Fall 2017 Midterm Review Ryan Huang 10/12/17 CS 318 Midterm Review 2 Midterm October 17 th Tuesday 9:00-10:20 am at classroom Covers material before virtual memory

More information

Data Structure and Algorithm Homework #3 Due: 2:20pm, Tuesday, April 9, 2013 TA === Homework submission instructions ===

Data Structure and Algorithm Homework #3 Due: 2:20pm, Tuesday, April 9, 2013 TA   === Homework submission instructions === Data Structure and Algorithm Homework #3 Due: 2:20pm, Tuesday, April 9, 2013 TA email: dsa1@csientuedutw === Homework submission instructions === For Problem 1, submit your source code, a Makefile to compile

More information

Total Points 100 (One Hundred)

Total Points 100 (One Hundred) Project 2: Implementing Reliable Data Transfer Protocol (CS3516 A18) Due: Sep 28, 2018 F, 11:59 PM Total Points 100 (One Hundred) 1. Overview In this programming assignment, you will be writing the sending

More information