Chapter 8: I/O functions & socket options

Similar documents
UNIT III - APPLICATION DEVELOPMENT. TCP Echo Server

Interprocess Communication Mechanisms

shared storage These mechanisms have already been covered. examples: shared virtual memory message based signals

Shell Execution of Programs. Process Groups, Session and Signals 1

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

Memory-Mapped Files. generic interface: vaddr mmap(file descriptor,fileoffset,length) munmap(vaddr,length)

Asynchronous Events on Linux

I/O Models. Kartik Gopalan

Interprocess Communication Mechanisms

Interprocess Communication Mechanisms

CSE398: Network Systems Design

Device-Functionality Progression

Chapter 12: I/O Systems. I/O Hardware

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

Other Interprocess communication (Chapter 2.3.8, Tanenbaum)

I/O Systems. Jo, Heeseung

Module 12: I/O Systems

UNIT IV- SOCKETS Part A

Answer to exercises chap 13.2

Input/Output Systems

Introduction. Interprocess communication. Terminology. Shared Memory versus Message Passing

I/O Systems. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Operating System: Chap13 I/O Systems. National Tsing-Hua University 2016, Fall Semester

TCP/IP Stack Introduction: Looking Under the Hood!

Chapter 13: I/O Systems

Chapter 13: I/O Systems

Operating Systems. 17. Sockets. Paul Krzyzanowski. Rutgers University. Spring /6/ Paul Krzyzanowski

Module 11: I/O Systems

Problem Set: Processes

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

Sockets Sockets Communication domains

[08] IO SUBSYSTEM 1. 1

Start of Lecture on January 20, Chapter 3: Processes

Chapter 13: I/O Systems

Chapter 13: I/O Systems. Chapter 13: I/O Systems. Objectives. I/O Hardware. A Typical PC Bus Structure. Device I/O Port Locations on PCs (partial)

Standards / Extensions C or C++ Dependencies POSIX.1 XPG4 XPG4.2 Single UNIX Specification, Version 3

csdesign Documentation

CISC2200 Threads Spring 2015

CSC209H Lecture 11. Dan Zingaro. March 25, 2015

CS330: Operating System and Lab. (Spring 2006) I/O Systems

Chapter 23 Process-to-Process Delivery: UDP, TCP, and SCTP 23.1

3.1 Introduction. Computers perform operations concurrently

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

VALLIAMMAI ENGINEERING COLLEGE. SRM Nagar, Kattankulathur QUESTION BANK

Signals, Synchronization. CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han

Building blocks for Unix power tools

Lecture 8: Other IPC Mechanisms. CSC 469H1F Fall 2006 Angela Demke Brown

Topics. Lecture 8: Other IPC Mechanisms. Socket IPC. Unix Communication

Module 12: I/O Systems

Lecture 7: Signals and Events. CSC 469H1F Fall 2006 Angela Demke Brown

Overview. Last Lecture. This Lecture. Daemon processes and advanced I/O functions

CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF MCA QUESTION BANK UNIT 1

Silberschatz and Galvin Chapter 12

hardware interrupts software interrupts

Interprocess Communication

by I.-C. Lin, Dept. CS, NCTU. Textbook: Operating System Concepts 8ed CHAPTER 13: I/O SYSTEMS

Embedded System Design

Chapter 2: Interprocess Communication

Input-Output (I/O) Input - Output. I/O Devices. I/O Devices. I/O Devices. I/O Devices. operating system must control all I/O devices.

- Knowledge of basic computer architecture and organization, ECE 445

User Datagram Protocol

Operating Systems 2010/2011

Concurrent Architectures - Unix: Sockets, Select & Signals

Light & NOS. Dan Li Tsinghua University

Chapter 13: I/O Systems. Operating System Concepts 9 th Edition

A Scalable Event Dispatching Library for Linux Network Servers

Contents. Part 1. Introduction and TCP/IP 1. Foreword Preface. xix. I ntroduction 31

Network Programming TDC 561

Introduction! Overview! Signal-driven I/O for Sockets! Two different UDP servers!

CS350: Final Exam Review

Chapter 13: I/O Systems

I/O AND DEVICE HANDLING Operating Systems Design Euiseong Seo

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

OPERATING SYSTEMS & Network OVERVIEW. 1: OS & Network Overview

Introduction to Computer Systems. Networks 2. c Theodore Norvell. The Sockets API

interface serially with the machine (through RS-232), 25-pin connectors

Overview. Thread Packages. Threads The Thread Model (1) The Thread Model (2) The Thread Model (3) Thread Usage (1)

Interprocess Communication Mechanisms

NETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science

Interprocess Communication Mechanisms

Chapter 12: I/O Systems

Chapter 13: I/O Systems

Chapter 12: I/O Systems. Operating System Concepts Essentials 8 th Edition

19: I/O. Mark Handley. Direct Memory Access (DMA)

Interconnecting Components

CSC209 Review. Yeah! We made it!

Outline. Option Types. Socket Options SWE 545. Socket Options. Out-of-Band Data. Advanced Socket. Many socket options are Boolean flags

CSE380 - Operating Systems. Communicating with Devices

SMD149 - Operating Systems

Introduction to Computers and Programming

ISA 563: Fundamentals of Systems Programming

MARIA COLLEGE OF ENGINEERING AND TECHNOLOGY, ATTOOR DEPARTMENT OF INFORMATION TECHNOLOGY NETWORK PROGRAMMING MANAGEMENT 2 MARKS QUESTIONS & ANSWERS

CS 134. Operating Systems. April 8, 2013 Lecture 20. Input/Output. Instructor: Neil Rhodes. Monday, April 7, 14

Hardware OS & OS- Application interface

I/O Systems. Amir H. Payberah. Amirkabir University of Technology (Tehran Polytechnic)

The Kernel Abstraction

Chapter 13: I/O Systems

Problem Set: Processes

IT 341: Introduction to System

Review: Hardware user/kernel boundary

Transcription:

Chapter 8: I/O functions & socket options 8.1 Introduction I/O Models In general, there are normally two phases for an input operation: 1) Waiting for the data to arrive on the network. When the packet arrives, copy it into a buffer within the kernel. 2) Copy this data from the kernel s buffer into the application buffer. Under UNIX, there are five available I/O models: Blocking I/O (blocking). Nonblocking I/O (polling). I/O Multiplexing (select and poll). Signal driven I/O (SIGIO). Asynchronous I/O (Posix.1). 8.1.1 Synchronous I/O versus Asynchronous I/O.1 definitions: A synchronous I/O operation causes the requesting process to be blocked until that I/O operation completes. An asynchronous I/O operation does not cause the requesting process to be blocked. Four I/O models belong to this category: Blocking. Non blocking. I/O multiplexing. Signal-driven I/O. 8.1.2 Blocking I/O Model: The most prevalent model; by default, all sockets are blocking. Blocking occurs under the following circumstances: Read: When no data has arrived yet; example a block in read() or recvfrom(). Write: When the internal buffers are full and waiting for transmission, the program requests for more data to be sent. Connection: When accept() and connect()find no pending connection in the listening queue. An application calls recvfrom. The system call does not return until the datagram arrives and is copied into application buffer, or an error occurs. The application is blocked the entire time from when it calls recvfrom until it returns. When recvfrom returns OK, the application processes the datagram. The most common error is the system call being interrupted by a signal. our process is blocked the entire time from when it calls recvfrom until it returns. When recvfrom returns successfully, our application processes the datagram. Fig 8.1 show Blocking I/O model.

8.1.3 Nonblocking I/O (polling). When an I/O operation requested by a process cannot be completed, the kernel does not put the process to sleep, but returns (immediately) an error. Can be used for a process that is monitoring more than one I/O. Use fcntl()system call to set O_NONBLOCK of the file descriptor. An application calls recvfrom. In nonblocking, the application sits in a loop calling recvfrom on a nonblocking descriptor (polling) & it can be a waste of CPU time. Fig 8.2 show Nonblocking I/O model

8.1.4 I/O Multiplexing (select and poll). An alternative to non blocking here the process is blocked until I/O is available from any of a set of file descriptors. We need the capability to tell the kernel that we want to be notified if one or more I/O conditions are ready. A client is handling two inputs at the same time: a standard input and a TCP Socket. The client is blocked in a call to fgets (on standard input). What happened when the server TCP process is killed? The server process correctly sends a FIN. But, the client never reads it because it is blocked in fgets. In I/O multiplexing, a call to select() or poll() is made and it blocks in one of these two systems calls, instead of blocking in the actual I/O system call. An application uses select() to wait for the datagram socket to be readable. The application is blocked in select() call, when the socket is not readable. select() returns when the socket is readable. Then, call recvfrom to copy the datagram into application buffer. Advantage: we can wait for more than one descriptor to be ready. Disadvantage: Similar to blocking I/O but requires two system calls. Fig 8.3 I/O multiplexing model

8.1.5 Signal driven I/O (SIGIO). The kernel will give notification with the SIGIO signal when the descriptor is ready so it is called signal driven I/O. Steps: Enable the socket for signal driven I/O. Install a signal handler using sigaction system call & return immediately, process is not blocked. When the datagram is ready to be read, the SIGIO signal is generated for the process. Process reads the datagram. The advantage of this model is that the process is not blocked while waiting for the datagram to arrive. The main loop can continue executing and just wait to be notified by the signal handler that either the data is ready to process or that the datagram is ready to be read. Fig 8.4 Signal-Driven I/O model