CS 351 Week 15. Course Review

Similar documents
CS 351 Week Advanced UNIX Programming: Rochkind, Marc J. 1. To learn about System Interprocess Communication (IPC). 2. To learn about Sockets.

Interprocess Communication

UNIX Sockets. Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E.

EEC-484/584 Computer Networks

Lecture 2. Outline. Layering and Protocols. Network Architecture. Layering and Protocols. Layering and Protocols. Chapter 1 - Foundation

What s an API? Do we need standardization?

Session NM056. Programming TCP/IP with Sockets. Geoff Bryant Process software

Ports under 1024 are often considered special, and usually require special OS privileges to use.

STUDY OF SOCKET PROGRAMMING

Networked Applications: Sockets. End System: Computer on the Net

Processes communicating. Network Communication. Sockets. Addressing processes 4/15/2013

CS 428/528 Computer Networks Lecture 01. Yan Wang

Socket Programming for TCP and UDP

Client Server Computing

TCP: Three-way handshake

Networked Applications: Sockets. Goals of Todayʼs Lecture. End System: Computer on the ʻNet. Client-server paradigm End systems Clients and servers

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

Group-A Assignment No. 6

CSE/EE 461 Lecture 14. Connections. Last Time. This Time. We began on the Transport layer. Focus How do we send information reliably?

Programming with TCP/IP. Ram Dantu

Systems software design NETWORK COMMUNICATIONS & RPC SYSTEMS

Oral. Total. Dated Sign (2) (5) (3) (2)

Lecture 7. Followup. Review. Communication Interface. Socket Communication. Client-Server Model. Socket Programming January 28, 2005

A Socket Example. Haris Andrianakis & Angelos Stavrou George Mason University

Unix Network Programming

sottotitolo Socket Programming Milano, XX mese 20XX A.A. 2016/17 Federico Reghenzani

Socket Programming. #In the name of Allah. Computer Engineering Department Sharif University of Technology CE443- Computer Networks

Tutorial on Socket Programming

CLIENT-SIDE PROGRAMMING

Network Communication

Outline. Distributed Computing Systems. Socket Basics (1 of 2) Socket Basics (2 of 2) 3/28/2014

Interprocess Communication Mechanisms

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

Interprocess Communication Mechanisms

Interprocess Communication Mechanisms

Programming Internet with Socket API. Hui Chen, Ph.D. Dept. of Engineering & Computer Science Virginia State University Petersburg, VA 23806

Socket Programming. CSIS0234A Computer and Communication Networks. Socket Programming in C

Elementary TCP Sockets

CSE 124 Discussion Section Sockets Programming 10/10/17

UNIX Sockets. COS 461 Precept 1

CSMC 412. Computer Networks Prof. Ashok K Agrawala Ashok Agrawala Set 2. September 15 CMSC417 Set 2 1

Agenda. Before we start: Assignment #1. Routing in a wide area network. Protocols more concepts. Internetworking. Congestion control

Chapter 6. The Transport Layer. Transport Layer 3-1

Outline. Distributed Computer Systems. Socket Basics An end-point for a IP network connection. Ports. Sockets and the OS. Transport Layer.

Socket Programming TCP UDP

MSc Integrated Electronics Networks Assignment. Investigation of TCP/IP Sockets and Ports. Gavin Cameron

Motivation of VPN! Overview! VPN addressing and routing! Two basic techniques for VPN! ! How to guarantee privacy of network traffic?!

Types (Protocols) Associated functions Styles We will look at using sockets in C Java sockets are conceptually quite similar

Hybrid of client-server and P2P. Pure P2P Architecture. App-layer Protocols. Communicating Processes. Transport Service Requirements

CSC209H Lecture 9. Dan Zingaro. March 11, 2015

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

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

Computer Networks Prof. Ashok K. Agrawala

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

Operating Systems. Review ENCE 360

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

Introduction to Asynchronous Programming Fall 2014

CPS 214: Computer Networks. Slides by Adolfo Rodriguez

A Client-Server Exchange

Review. Preview. Closing a TCP Connection. Closing a TCP Connection. Port Numbers 11/27/2017. Packet Exchange for TCP Connection

A. Basic Function Calls for Network Communications

CS 326: Operating Systems. Process Execution. Lecture 5

Inter-Process Communication

Introduction for SPI mapping Service Discovery Interoperability Testing. 20, Sep PWG Fumio Nagasaka

Christian Tschudin (basierend auf einem Foliensatz von C. Jelger und T. Meyer) Departement Mathematik und Informatik, Universität Basel

Outline. Operating Systems. Socket Basics An end-point for a IP network connection. Ports. Network Communication. Sockets and the OS

Network Software Implementations

CS 640: Computer Networking

Socket Programming. Sungkyunkwan University. Hyunseung Choo Copyright Networking Laboratory

ELEC / COMP 177 Fall Some slides from Kurose and Ross, Computer Networking, 5 th Edition

Socket Programming. Dr. -Ing. Abdalkarim Awad. Informatik 7 Rechnernetze und Kommunikationssysteme

The TCP Protocol Stack

Computer Network Lab, SS Fachgebiet Technische Informatik, Joachim Zumbrägel. Overview. Sockets. Sockets in C.

Socket Programming(2/2)

Sockets 15H2. Inshik Song

SOCKET PROGRAMMING. What is a socket? Using sockets Types (Protocols) Associated functions Styles

CptS 360 (System Programming) Unit 17: Network IPC (Sockets)

CS4700/CS5700 Fundamentals of Computer Networking

CSE 333 Section 8 - Client-Side Networking

Introduction to Socket Programming

Goals of this Lecture

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

I/O Management! Goals of this Lecture!

I/O Management! Goals of this Lecture!

W4118 Operating Systems. Junfeng Yang

Sockets. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

(Refer Slide Time: 1:09)

Concurrent Architectures - Unix: Sockets, Select & Signals

CS321: Computer Networks Introduction to Application Layer

Sistemas Operativos /2016 Support Document N o 1. Files, Pipes, FIFOs, I/O Redirection, and Unix Sockets

Client-side Networking

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

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

CSC209 Review. Yeah! We made it!

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

Sockets and Parallel Computing. CS439: Principles of Computer Systems April 11, 2018

ECE 598 Advanced Operating Systems Lecture 23

PA #2 Reviews. set_name, get_name, del_name. Questions? Will be modified after PA #4 ~

Asynchronous Events on Linux

Processes and Threads

Transcription:

CS 351 Week 15 Course Review Objectives: 1. To review the contents from different weeks. 2. To have a complete understanding of important concepts from different weeks. Concepts: 1. Important Concepts from Different weeks Outline: 1. Final Exam Instructions 2. Discussion of important topics References: 1. Weekly Notes for the entire course CS 351 Week 15 Page 1

CS 351: Week 15 Lecture Notes Datatypes: i) The different data types are: a) Integer b) Character c) Boolean ii) An identifier is used for any variable, function, data definition, etc. An identifier is a combination of alphanumeric characters, the first being a letter of the alphabet or an underline.the remaining being any letter of the alphabet, any numeric digit, or the underline. iii) void main() { int a,b,c; printf( /n enter any two integer numbers ); scanf( \n %d,%d,&a,&b); c=a+b; printf(\n The addition of two numbers is %d,c); Virtual Memory: i) Virtual memory is hardware technique where the system appears to have more memory that it actually does. This is done by time-sharing, the physical memory and storage parts of the memory one disk when they are not actively being used. ii) Benefits of virtual paging: Protection - a process's page numbers correspond only to physical memory addressable by the process Allocation - physical pages allocated/de-allocated as needed by processes (memory on demand) Signal Handling: An application program can specify a function called a signal handler to be invoked when a specific signal is received. When a signal handler is invoked on receipt of a signal, it is said to catch the signal. A process can deal with a signal in one of the following ways: The process can let the default action happen The process can block the signal (some signals cannot be ignored) The process can catch the signal with a handler. Signal handlers usually execute on the current stack of the process. This lets the signal handler return to the point that execution was interrupted in the process. CS 351 Week 15 Page 2

This can be changed on a per-signal basis so that a signal handler executes on a special stack. If a process must resume in a different context than the interrupted one, it must restore the previous context itself ii) Binary Search int binsearch(int x, int v[], int n) { int low, high, mid; low = 0; high = n - 1; while (low <= high) { mid = (low + high) / 2; if (x < v[mid]) { high = mid - 1; else if ( x > v[mid]) { low = mid + 1; else /* found match */ return mid; return -1; /* no match */ Message Passing - Underlying state changes are hidden because message passing abstraction is used to implement message sending. - Message passing model based programming languages define message passing as sending of a data item to communication end point. - Used as a means of inter-process communication - Different message passing styles: o Distributed Computing o SOAP o Actor Model Implementations o Amorphous Computing o Anti-objects - Message Passing Models are one of several computational models for conceptualizing program operations. - Message Passing Model defined as: o Set of processes having only local memory o Processes communicate by sending and receiving messages o Transfer of data between processes requires co-operative operations to be performed by each process. - Other Models include: CS 351 Week 15 Page 3

o Data parallelism o Shared memory o Remote memory operation o Threads o Etc., - Advantages Hardware match Functionality Performance MPI stands for Message Passing Interface. MPI is a library specification for message-passing, proposed as a standard by a broadly based committee of vendors, implementors, and users. The MPI standard is available. Timers: MPI was designed for high performance on both massively parallel machines and on workstation clusters. MPI is widely available, with both free available and vendor-supplied implementations. MPI was developed by a broadly based committee of vendors, implementors, and users. Information for implementors of MPI is available. Test Suites for MPI implementations are available. i) Timers are registered events that fire at programmed interval. ii) Two methods o WM_TIMER message (simpler, for single timer) o Callback function (multiple timers applications) The host is responsible for reading the port number from each packet it receives to decide which program should receive that chunk of data. o If you like, you can think of the packets as letters sent via snail mail, the IP address like the street address. Then the port is the apartment or suite numberas a general (but far from absolute) rule each computer only has one Internet address. However, computers often need to communicate with more than one host at a time. For example, there may be multiple ftp sessions, a few web connections, and a chat program all running at the same time. o To make this possible the computer's network interface is logically subdivided into 65,536 different ports. This is an abstraction. A port does not represent anything physical like a serial or parallel port. However as data traverses the Internet in CS 351 Week 15 Page 4

packets, each packet carries not only the address of the host but also the port on that host to which it's aimed. o As a general (but far from absolute) rule each computer only has one Internet address. However, computers often need to communicate with more than one host at a time. For example, there may be multiple ftp sessions, a few web connections, and a chat program all running at the same time. o To make this possible the computer's network interface is logically subdivided into 65,536 different ports. This is an abstraction. A port does not represent anything physical like a serial or parallel port. However as data traverses the Internet in packets, each packet carries not only the address of the host but also the port on that host to which it's aimed Sockets: - Socket is an abstraction for an end point of communication that can be manipulated with a file descriptor. - It is an abstract object from which messages are sent and received. - Sockets are created within a communication domain just as files are created within a file system. - A communication domain is an abstraction introduced to bundle common properties of processes communicating through sockets. Example: UNIX domain, internet domain. Interprocess Communication - Typical applications today consist of many cooperating processes either on the same host or on different hosts. - For example, consider a client-server application. How to share (large amounts of) data? - How to share files and avoid contention issues? - We want a general mechanism that will work for processes irrespective of their location. IPC: Purpose - Data Transfer - Sharing Data - Event Notification - Process Control IPC at different Levels: - Process Level- Pipes - OS Level- Sockets - Plain Language Level- Distriubuted System Methods Socket Address: CS 351 Week 15 Page 5

Socket address is nothing but the combination of IP address and the port number. The format of the socket address is something like the one given below: Socket address= <ip address>:<port address> Eg: 192.168.1.1:8902 Socket Functions: - Creating a Socket o socket system call create a socket on demand. o int socket(int domain, int type, int protocol) Domain: PF_INET (Internet), PF_UNIX (local) Type: SOCK_STREAM, SOCK_DGRAM, SOCK_RAW Protocol: 0 usually for IP (see /etc/protocols for details) - Binding a Socket o A socket is created without any association to local or destination address. It is possible to bind the socket to a specific host and in it a specific port number. o int bind(int socket struct sockaddr *addr int addr_len) - Closing a socket o close (socid); closes the specified socket. This is done by a process or thread when it no longer needs the socket connection. o close(int socket) - Connecting o A socket is created in an unconnected state, which means that the socket is not associated with any destination. o An application program should call connect to establish a connection before it can transfer data thru reliable stream socket. For datagrams connect is not required but recommended. o int connect(int socket, struct sockaddr *addr, int addr_len) - Sending o Five different system calls : send, sendto, sendmsg, write, writev o send, write and writev work only with connected sockets. No parameter for destination address. Prior connect should be present for communication. o int send(int socket, char *buf, int blen, int flags) - Receiving o Five different calls are available: read, readv, recv, recvfrom, recvmsg o read, readv, and recv are for connection-oriented comm. o int recv(int socket, char *buf, int blen, int flags) CS 351 Week 15 Page 6

- Listening o To avoid having protocols reject incoming request, a server may have to specify how many messages need to be queued until it has time to process them. o Example: listen(socket,length); - Accepting o Wait for the call. o int accept(int socket, struct sockaddr *addr, int addr_len) Threads lightweight processes o A sequence of instructions being executed when there is no external intervention. o Sometimes we want to share data as well as code. o Easier to create than a process. o They provide a nice encapsulation of a problem within a process rather than multiple processes. o Easier to switch between threads than between processes. o Typical uses splitting work across processors (shared memory multiprocessor) added responsiveness (handle user input while still finishing another function) controlling and monitoring other threads server applications can help program abstraction Thread implementation o User-level The OS only sees one thread per process. The process constructs other threads by user-level library calls or by hand. User-level control over starting and stopping threads. Usually a request is made to the OS to interrupt the process regularly (an alarm clock) so that the process can schedule another thread. The state of threads in the library code does not correspond to the state of the process. o System-level The OS knows about multiple threads per process. Threads are constructed and controlled by system calls. The system knows the state of each thread. User-level thread advantages Works even if the OS doesn't support threads. Some implementations of Java have user-level threads because the underlying OS doesn t. Ruby provides threads even on DOS. Easier to create - no system call. Just a normal library procedure call. CS 351 Week 15 Page 7

No switch into kernel mode (this saves time). Control can be application specific. Sometimes the OS doesn t give the type of control an application needs. Example: precise priority levels, changing scheduling decisions according to state changes Easier to switch between - saves two processor mode changes. System-level thread advantages o Each thread can be treated separately. o Rather than using the timeslice of one process over many threads. o Should a process with 100 threads get 100 times the CPU time of a process with 1 thread? o A thread blocking in the kernel doesn't stop all other threads in the same process. o With the user-level threads if one thread blocks for IO the OS sees the process as blocked for IO. o On a multiprocessor different threads can be scheduled on different processors. o This can only be done if the OS knows about the threads. Jacketing: o The major problem with user-level threads is the blocking of all threads within a process when one blocks. o A possible solution is known as jacketing. o A blocking system call has a user-level jacket. o The jacket checks to see if the resource is available. Example: A device when it is free. o If not another thread is started. o When the calling thread is scheduled again (by the thread library) it once again checks the state of the device. o So there has to be some way of determining if resources are available to accept requests immediately. Pipes: - Provides interprocess communication channel - Processes must be on the same machine - Used mostly for filters - A filter is a process that reads from stdin and writes to stdout - Pipe is a communication channel abstraction Process A can write to one end using write system call Process B can read from the other end using read system call - System call - int pipe( int fd[2] ); return 0 upon success 1 upon failure fd[0] is open for reading fd[1] is open for writing. CS 351 Week 15 Page 8