Today: VM wrap-up Select (if time) Course wrap-up Final Evaluations

Similar documents
I/O Models. Kartik Gopalan

CONCURRENCY MODEL. UNIX Programming 2014 Fall by Euiseong Seo

Network Programming TDC 561

ISA 563: Fundamentals of Systems Programming

CSE 43: Computer Networks Structure, Threading, and Blocking. Kevin Webb Swarthmore College September 14, 2017

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song

CISC2200 Threads Spring 2015

Εργαστήριο 9 I/O Multiplexing

10. I/O System Library

Network Games Part II. Architecture of Network Game

Concurrent Programming. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

CSci 4061 Introduction to Operating Systems. IPC: Basics, Pipes

Concurrent Server Design Multiple- vs. Single-Thread

Any of the descriptors in the set {1, 4} have an exception condition pending

UNIT III - APPLICATION DEVELOPMENT. TCP Echo Server

Assignment 2 Group 5 Simon Gerber Systems Group Dept. Computer Science ETH Zurich - Switzerland

Network programming(ii) Lenuta Alboaie

CSC209H Lecture 10. Dan Zingaro. March 18, 2015

Version Control with Git and What is there in Project 1 PALLABI GHOSH COMPUTER NETWORKS RECITATION 1

ECE 650 Systems Programming & Engineering. Spring 2018

CSci 4061 Introduction to Operating Systems. (Advanced Control Signals)

call connect call read call connect ret connect call fgets Client 2 blocks waiting to complete its connection request until after lunch!

Introduction to Asynchronous Programming Fall 2014

COMP/ELEC 429/556 Introduction to Computer Networks

EE 122: Sockets. Motivation. Sockets. Types of Sockets. Kevin Lai September 11, 2002

33. Event-based Concurrency

PROCESSES AND THREADS THREADING MODELS. CS124 Operating Systems Winter , Lecture 8

NETWORK AND SYSTEM PROGRAMMING. I/O Multiplexing: select and poll function

CSE 333 Lecture fork, pthread_create, select

Asynchronous Events on Linux

CS118 Discussion Week 2. Taqi

Topics for this Week

CSE 333 Lecture non-blocking I/O and select

CSC209H Lecture 11. Dan Zingaro. March 25, 2015

Concurrent Servers Dec 2, 2009"

Global Employee Location Server

Three Basic Mechanisms for Creating Concurrent Flows. Systemprogrammering 2009 Föreläsning 10 Concurrent Servers. Process-Based Concurrent Server

We start by looking at what s known as event-based programming: we write code that responds to events coming from a number of sources.

Introduction to Socket Programming

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

Iterative Servers The course that gives CMU its Zip! Iterative servers process one request at a time. Concurrent Servers

Learning from Bad Examples. CSCI 5828: Foundations of Software Engineering Lecture 25 11/18/2014

CONCURRENT PROGRAMMING. Lecture 5

Redes de Computadores (RCOMP)

CSC369 Lecture 2. Larry Zhang

CS 43: Computer Networks. 07: Concurrency and Non-blocking I/O Sep 17, 2018

Engineering Robust Server Software

CS 153 Design of Operating Systems Winter 2016

Network Programming in C: The Berkeley Sockets API. Networked Systems 3 Laboratory Sessions

CPSC 410/611: File Management. What is a File?

Lecture 5 Overview! Last Lecture! This Lecture! Next Lecture! I/O multiplexing! Source: Chapter 6 of Stevens book!

CSci 4061 Introduction to Operating Systems. IPC: Basics, Pipes

CSci 4061 Introduction to Operating Systems. IPC: Basics, Pipes

December 8, epoll: asynchronous I/O on Linux. Pierre-Marie de Rodat. Synchronous/asynch. epoll vs select and poll

CSC209 Review. Yeah! We made it!

Project 1: A Web Server Called Liso

CS4961 Parallel Programming. Lecture 12: Advanced Synchronization (Pthreads) 10/4/11. Administrative. Mary Hall October 4, 2011

CSC369 Lecture 2. Larry Zhang, September 21, 2015

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs.

Redesde Computadores(RCOMP)

Exception-Less System Calls for Event-Driven Servers

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

Chapter 8: I/O functions & socket options

Midterm Exam Answers

Problem 1: Concepts (Please be concise)

Input / Output. Kevin Webb Swarthmore College April 12, 2018

15-213: Final Exam Review

CSE 333 Final Exam June 6, 2017 Sample Solution

Che-Wei Chang Department of Computer Science and Information Engineering, Chang Gung University

CS-537: Final Exam (Spring 2011) The Black Box

Example Questions for Midterm EE122, Fall 2008 EECS Berkeley

RCU. ò Walk through two system calls in some detail. ò Open and read. ò Too much code to cover all FS system calls. ò 3 Cases for a dentry:

VFS, Continued. Don Porter CSE 506

Lecture 15: I/O Devices & Drivers

OpenACC Course. Office Hour #2 Q&A

More Types of Synchronization 11/29/16

CS 140 Project 4 File Systems Review Session

Concurrent Programming April 21, 2005

PROCESS CONCEPTS. Process Concept Relationship to a Program What is a Process? Process Lifecycle Process Management Inter-Process Communication 2.

I/O Multiplexing. Dec 2009

CS11 Java. Fall Lecture 7

Last time: introduction. Networks and Operating Systems ( ) Chapter 2: Processes. This time. General OS structure. The kernel is a program!

File Systems: Consistency Issues

CS370 Operating Systems

"#' %#& Lecture 7: Organizing Game Clients and Servers. Socket: Network communication endpoints. IP address: IP-level name of a machine

Dr. Rafiq Zakaria Campus. Maulana Azad College of Arts, Science & Commerce, Aurangabad. Department of Computer Science. Academic Year

Qualifying exam: operating systems, 1/6/2014

dnotify's interface to user space is signals. Yes, seriously, signals!

Virtual File System. Don Porter CSE 306

Kolmo. Making automation & configuration easier. bert hubert. -

CS 431 Introduction to Computer Systems Solutions Mid semester exam 2005

CS-537: Midterm Exam (Fall 2013) Professor McFlub

DISTRIBUTED SYSTEMS [COMP9243] Lecture 3b: Distributed Shared Memory DISTRIBUTED SHARED MEMORY (DSM) DSM consists of two components:

CS 3214 Final Exam. To be considerate to your fellow students, if you leave early, do so with the least amount of noise.

CS370 Operating Systems

Computer Science 330 Operating Systems Siena College Spring Lab 5: Unix Systems Programming Due: 4:00 PM, Wednesday, February 29, 2012

SmartHeap for Multi-Core

Networks and distributed computing

CS510 Operating System Foundations. Jonathan Walpole

Transcription:

Today: VM wrap-up Select (if time) Course wrap-up Final Evaluations

Program structure int A[1024][1024] ; Each row is stored in one page Ignore code page in this example One frame allocated Program 1 for (j = 0; j< 1024; j++) for (i = 0; i< 1024;i++) A[i][j] = i*j; 1024 x 1024 page faults 2

Program 2 for (i = 0; i< 1024; i++) for (j = 0; j< 1024;j++) A[i][j] = i*j; 1024 page faults 3

Asynchrony Many programs need to establish multiple I/O channels Need concurrent channels e.g. webserver requests and replies http files and images Challenge: don t know which channels are ready We ve seen many ways to handle this

One way Threads Use a separate thread to handle each I/O channel Each thread manages channel with standard blocking calls read and write Potential Issues? threads must be able to block safely threads consume resources Lab #4

Other options Polling-based (lab #2) use non-blocking I/O on read/write retry if nothing there Problems with this solution: lots of system calls! complexity performance how often to retry?

Other options (cont d) Set up signal handlers to deal with I/O completion events (SIGIO) For some I/O devices, you can set O_NONBLOCK O_ASYNC and get sent a signal when input or output is ready the appeal? works for network sockets Setup SIGIO handler Get an fd corresponding to network connection Use fcntl to set properties on this fd fd = accept (.); Emulated this in lab #3 fcntl (fd, F_SETFL, O_NONBLOCK O_ASYNC);

Approach is limited Using I/O signals limited to certain channel types works for a single channel any multiplexing has to be layered on top multiple channels: which channel caused the signal?

Another option: Select More efficient polling and multiplexing Use select() to wait for multiple I/O channels simultaneously select generally requires fewer system calls blocks if NOTHING is ready

#include <sys/select.h> I/O multiplexing int select (int n, fd_set *readfds, NULL, NULL, struct timeval *timeout); n is the max fd # to check (max_fd + 1) readfds contain fds of interest; can be NULL, if don t care timeval is the timeout how long to wait, NULL if forever returns -1 on failure modifies fd_set to indicate those that are ready

Using select (cont d) Write your program as an event-loop Before each call to select, set the fd set to be monitored fds as select will clear bits not ready when it returns Set n appropriately (max(fd)+1) Call select to see what is ready Act on the ready fd (i.e. do the I/O) Repeat

Init and set fd bits: Using select (cont d) FD_ZERO (fd_set *set); // init a set FD_SET (int fd, fd_set *set); // set this fd for monitoring FD_CLR (int fd, fd_set *set); // clear a bit FD_ISSET (int fd, fd_set *set); // is fd in the ready set?

Using select Example: want to read from multiple sources while (1) { // set/restore monitored fd_set each time through the loop FD_ZERO (&readset); FD_SET (fd1, &readset); FD_SET (fd2, &readset); max_fd = max (fd1, fd2); select (max_fd+1, &readset, NULL, NULL, NULL); if (FD_ISSET (fd1, &readset) read (fd1,.); if (FD_ISSET (fd2, &readset) read (fd2,.); }

Using select (cont d) Select blocks until >=1 fd is ready Returns a value > 0 Select returns due to timeout Returns a value = 0 Select returns a value < 0 if an error in select call

Lab #2 without non-blocking reads! fd_set rfds; FD_ZERO(&rfds); for (i=0; i<total_tabs; i++) { if(channel[i].child_to_parent_fd[0]!=0) FD_SET(channel[i].child_to_parent_fd[0], &rfds); if(channel[i].child_to_parent_fd[0] > max_fd) max_fd = channel[i].child_to_parent_fd[0]; } select(max_fd + 1, &rfds, NULL, NULL, NULL); for(i=0; i<total_tabs; i++){ if(fd_isset(channel[i].child_to_parent_fd[0], &rfds)){ //Child 'i' has sent a request

Course wrap-up tell me about 4061 Systems are complex beasts Programming them is hard - concurrency - asynchrony - multiple interacting components - metrics (sometimes competing): performance, reliability, security - stakeholders: user, admin, system

Abstraction hides complexity promotes usability Systems programming abstractions Process: running program/resource container I/O: data movement to/from external device File: container for data Directory: container for related files Pipes/Mailbox: communication stream Thread: control Synchronization: CV, semaphore, lock Socket: communication end-point

Want more? Take CSCi 5103 Operating Systems

The Final: Closed: I ll give APIs 90% incremental since exam #2 semaphores, CVs, ME, BB, RW, barriers network programming: sockets, addressing, etc. virtual memory 10% older Length of an in-class exam ~ 35% short answer ~ 65% longer answer

3 Longer questions (programming/analysis): Virtual memory Network programming Synchronization Will post a sample exam