Process Concept: views of a process Process Scheduling CSCI 6730/ 4730 Operating Systems

Similar documents
Chapter 3: Processes: Outline. Operating Systems. Remote Procedure Calls (RPC) Client-Server Remote Machine Communication Mechanisms

System Models and Communication

Desarrollo de Aplicaciones en Red. El modelo de comunicación. General concepts. Models of communication. Message Passing

Remote Procedure Call

Lecture 12 RPC RPC RPC. Writing an RPC Program. Sun RPC RPC. February 9+11, 2005

03 Remote invocation. Request-reply RPC. Coulouris 5 Birrel_Nelson_84.pdf RMI

RPC Programming. Some knowledge of C & Unix A network with at least two connected machines.

Sun Remote Procedure Call Mechanism

Remote Procedure Calls, TLI, STREAMS

Remote Procedure Calls (RPC)

C 1. Recap: Finger Table. CSE 486/586 Distributed Systems Remote Procedure Call. Chord: Node Joins and Leaves. Recall? Socket API

RPC Paradigm. Lenuta Alboaie Andrei Panu

CSE 660 Lab 2 Khoi Pham Thanh Ho April 27 th, 2015

Inter-process Communication: RPC

Chapter 4: Processes

Processes. CSE 2431: Introduction to Operating Systems Reading: Chap. 3, [OSC]

Remote Procedure Call Implementations

PRINCIPLES OF OPERATING SYSTEMS

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco

Chapter 3: Client-Server Paradigm and Middleware

C BOOTCAMP DAY 2. CS3600, Northeastern University. Alan Mislove. Slides adapted from Anandha Gopalan s CS132 course at Univ.

Processes. Electrical and Computer Engineering Stephen Kim ECE/IUPUI RTOS & Apps 1

Chapter 5: Remote Invocation. Copyright 2015 Prof. Amr El-Kadi

Processes. Operating System Concepts with Java. 4.1 Sana a University, Dr aimen

Last Class: RPCs. Today:

Distributed Program Design Typical Sockets Approach. Remote Procedure Call. Remote Subroutine

Part Two - Process Management. Chapter 3: Processes

COMMUNICATION PROTOCOLS: REMOTE PROCEDURE CALL (RPC)

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications

Process. Program Vs. process. During execution, the process may be in one of the following states

EECS 482 Introduction to Operating Systems

Communication. Communication. Distributed Systems. Networks and protocols Sockets Remote Invocation Messages Streams. Fall /10/2001 DoCS

Chapter 4: Processes. Process Concept

Tutorial 1 C Tutorial: Pointers, Strings, Exec

Chapter 4: Processes

RPC and RMI. 2501ICT Nathan

RPC flow. 4.3 Remote procedure calls IDL. RPC components. Procedure. Program. sum (j,k) int j,k; {return j+k;} i = sum (3,7); Local procedure call

Signal Example 1. Signal Example 2

Dynamic memory allocation

6 Remote Procedure Call (RPC)

Remote Procedure Calls CS 707

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community

Computer Systems Assignment 2: Fork and Threads Package

University of Pittsburgh Computer Science Department

Distributed Systems 8. Remote Procedure Calls

Interprocess Communication

Remote Invocation. Today. Next time. l Overlay networks and P2P. l Request-reply, RPC, RMI

Kurt Schmidt. October 30, 2018

Chapter 4: Processes. Process Concept. Process State

Communication. Distributed Systems Santa Clara University 2016

Chapter 3: Processes. Chapter 3: Processes. Process in Memory. Process Concept. Process State. Diagram of Process State

Operating Systems. 18. Remote Procedure Calls. Paul Krzyzanowski. Rutgers University. Spring /20/ Paul Krzyzanowski

Unix-Linux 2. Unix is supposed to leave room in the process table for a superuser process that could be used to kill errant processes.

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.

Lecture 03 Bits, Bytes and Data Types

COP 4610: Introduction to Operating Systems (Spring 2016) Chapter 3: Process. Zhi Wang Florida State University

What Is A Process? Process States. Process Concept. Process Control Block (PCB) Process State Transition Diagram 9/6/2013. Process Fundamentals

Chapter 3: Processes. Operating System Concepts 8 th Edition,

The University of Nottingham

CSci Introduction to Distributed Systems. Communication: RPC In Practice

From Java to C. Thanks to Randal E. Bryant and David R. O'Hallaron (Carnegie-Mellon University) for providing the basis for these slides

Chapter 3: Processes

CS153: Communication. Chengyu Song. Slides modified from Harsha Madhyvasta, Nael Abu-Ghazaleh, and Zhiyun Qian

Today CSCI Communication. Communication in Distributed Systems. Communication in Distributed Systems. Remote Procedure Calls (RPC)

Programs. Function main. C Refresher. CSCI 4061 Introduction to Operating Systems

CS551 Object Oriented Middleware (I) Outline. Computer Networks. Computer Networks. Types of Middleware TCP UDP

CHAPTER - 4 REMOTE COMMUNICATION

CSci 4061 Introduction to Operating Systems. Programs in C/Unix

416 Distributed Systems. RPC Day 2 Jan 12, 2018

The UNIVERSITY of EDINBURGH. SCHOOL of INFORMATICS. CS4/MSc. Distributed Systems. Björn Franke. Room 2414

COP 4610: Introduction to Operating Systems (Spring 2014) Chapter 3: Process. Zhi Wang Florida State University

3. Remote Procedure Call

Slide Set 9. for ENCM 335 in Fall Steve Norman, PhD, PEng

CSCE 455/855 Distributed Operating Systems

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 14

Distributed Systems. How do regular procedure calls work in programming languages? Problems with sockets RPC. Regular procedure calls

Thread Fundamentals. CSCI 315 Operating Systems Design 1

The Big Picture So Far. Chapter 4: Processes

CSC209 Review. Yeah! We made it!

CSC 634: Networks Programming

RMI: Design & Implementation

Message Passing vs. Distributed Objects. 5/15/2009 Distributed Computing, M. L. Liu 1

CMPE-013/L. Introduction to C Programming

CMPT 115. C tutorial for students who took 111 in Java. University of Saskatchewan. Mark G. Eramian, Ian McQuillan CMPT 115 1/32

Lecture 4: Outline. Arrays. I. Pointers II. III. Pointer arithmetic IV. Strings

Chapter 3: Processes. Operating System Concepts Essentials 8 th Edition

Chapter 5: Processes & Process Concept. Objectives. Process Concept Process Scheduling Operations on Processes. Communication in Client-Server Systems

Week 2 Intro to the Shell with Fork, Exec, Wait. Sarah Diesburg Operating Systems CS 3430

CSci Introduction to Distributed Systems. Communication: RPC

CSCI 2132 Final Exam Solutions

The Big Picture So Far. Chapter 4: Processes

CHAPTER 3 - PROCESS CONCEPT

Notice: This set of slides is based on the notes by Professor Perrone of Bucknell and the textbook authors Silberschatz, Galvin, and Gagne

Diagram of Process State Process Control Block (PCB)

Process Concept. Chapter 4: Processes. Diagram of Process State. Process State. Process Control Block (PCB) Process Control Block (PCB)

Chapter 4: Processes

416 Distributed Systems. RPC Day 2 Jan 11, 2017

Chapter 3: Processes. Operating System Concepts 9 th Edition

ECE264 Fall 2013 Exam 3, November 20, 2013

Transcription:

Chapter 3: Processes: Outline Process Concept: views of a process Process Scheduling CSCI 6730/ 4730 Operating Systems Operations on Processes Cooperating Processes Inter Process Communication (IPC) RPC: Processes» Local Pipe Shared Memory Messages (Queues)» Remote Lower Level: Sockets, MPI, Myrinet Higher Level: RPC, RMI, WebServices, CORBA, 2 Client-Server Remote Machine Communication Mechanisms Remote Procedure Calls (RPC) Socket communication (Possible bonus project) Remote Procedure Calls (Project next week). Remote Method Invocation (Briefly, on your own) Inter-machine process to process communication» Abstract procedure calls over a network:» rusers, rstat, rlogin, rup => daemons at ports Registered library calls (port mapper)» Hide message passing I/O from programmer Looks (almost) like a procedure call -- but client invokes a procedure on a.» Pass arguments get results» Fits into high-level programming language constructs 3» Well understood 4

Remote Procedure Calls (RPC) Remote Procedure Calls RPC High level view:» Calling process attempt to call a remote routine on» Calling process (client) is suspended» Parameters are passed across network to a process» Server executes procedure» Return results across network» Calling process resumes Usually built on top sockets (IPC) stubs client-side proxy for the actual procedure on the. The client-side stub locates the and marshalls the parameters. The -side stub receives this message, unpacks the marshalled parameters, and performs the procedure on the. 5 6 Association 5 tuple protocol, local-address, local-process, foreign-address, foreign-process Client/Server Model Using RPC RPC Association Between Machines call client return kernel XDR pack parameters client stub unpack results XDR unpack parameters stub pack results call return kernel Each RPC invocation by a client process calls a client stub, which builds a message and sends it to a stub Association between remote and local host» 5 tuple protocol, local-address, local-process, foreign-address, foreign-process Protocol : transport protocol typically TCP or UDP, needs to be common between hosts Local/foreign address: Typically the IP address Local/foreign process: Typically the port number (not PID) network The stub uses the message to generate a local procedure call to the If the local procedure call returns a value, the stub builds a message and sends it to the client stub, which receives it and returns the result(s) to the client 7 8

Binding Execution of RPC Registration data flow Client Process Portmapper Procedure Call data flow Server Process RPC application is packed into a program and is assigned an identifier (Port) Portmap : allocate port numbers for RPC programs 9 10 Remote Procedure Calls Tutorial ( linux journal ) Machine independent representation of data:» Differ if most/least significant byte is in the high memory address» External data representation (XDR) Allows more complex representation that goes beyond: htonl() routines. Fixed or dynamic address binding» Dynamic: Matchmaker daemon at a fixed address (given name of RPC returns port of requested daemon) rpcgen generates C code from a file written in RPC language <name>. x, e.g., avg.x Default output rpcgen Syntax Example Header file <name>.h avg.h XDR data type translate routines (from type in.h file) <name>_xdr.c avg._xdr.c stub program for <name>_svc.c avg_svc.c stub program for client <name>_clnt.c avg_clnt.c Application programmer (you) write code for:» Client routine (main program) ravg <host> <parameters>» Server program (e.g., actual code to compute average) 11 avg_proc.c 12

Application Routines of Interest avg.x : RPC language file const MAXAVGSIZE = 200; Server Routine:» average_1_svc(input_data, ): A avg_proc.c routine that is called from the stub that was generated by rpcgen struct input_data double input_data<200>; ; Client Routine: typedef struct input_data input_data;» average_prog_1() Local routine that parse parameter and that ultimately calls a local average_1 routine from generated code in avg_clnt.c that packs parameters (also uses routines in avg_xdr.c and sends code to. program AVERAGEPROG version AVERAGEVERS double AVERAGE(input_data) = 1; = 1; = 22855; /* port number */ 13 14 ravg.c : Client Program(1) ravg.c : Client Program (2) /* client code - calls client stub, xdr client, xdr xerver, stub, routine */ /* clnt_create( host, program, version, protocol) #include "avg.h" /* header file generated by rpcgen */ #include <stdlib.h> * generic client create routine from rpc library * program = AVERAGEPROG is the number 22855 * version = AVERAGEVERS is 1 /* local routine client prototype can be whatever you want */ * protocol = transfer protocol */ void averageprog_1( char* host, int argc, char *argv[] ) clnt = clnt_create( host, AVERAGEPROG, AVERAGEVERS, "udp" ); CLIENT *clnt; /* client handle, rpc.h */ if (clnt == NULL) clnt_pcreateerror( host ); /* rpc error library */ double char f, kkkkkk *result_1, *dp, *endptr; exit(1); int i; /* now call average routine 'just' like a local routine, but this will now go over network input_data average_1_arg; /* input_data rpc struct */ * average_1 is definined in the client stub in avg_clnt.c that was generated by rpcgen * send in ptr to the parameters or args in first field, and client handle in second average_1_arg.input_data.input_data_val = (double*) malloc(maxavgsize* sizeof(double)); * field (created in clnt_create ) average_1 ultimately calls clnt_call() macro see * man rpc, then calls the remote routine associated with the client handle dp = average_1_arg.input_data.input_data_val; /* ptr to beginning of data */ average_1_arg.input_data.input_data_len = argc - 2; /* set number of items */ * so AVERAGEPROG, VERSION */ result_1 = average_1( &average_1_arg, clnt ); if (result_1 == NULL) for( i = 1; i <= (argc - 2); i++ ) /* str to d ASCII string to floating point nubmer */ clnt_perror(clnt, "call failed:"); f = strtod( argv[i+1], &endptr); printf("value = %e\n", f); *dp = f; dp++; clnt_destroy( clnt ); printf( "average = %e\n",*result_1 ); /* end average_1 prodedure */ /* next slide main() */

ravg.c : Client Program (3) int main( int argc, char* argv[] ) char *host; avg_proc.c : Server Program (1) #include <rpc/rpc.h> #include "avg.h /* avg.h generated rpcgen */ #include <stdio.h> /* check correct syntax */ if( argc < 3 ) printf( "usage: %s _host value...\n", argv[0]); exit(1); if( argc > MAXAVGSIZE + 2 ) printf("two many input values\n"); exit(2); /* host name is in first parameter (after program name) */ host = argv[1]; averageprog_1( host, argc, argv); /* run locally on '' called by a remote client. */ static double sum_avg; /* routine notice the _1 the version number and notice the client handle, not used here, but * still needs to be a parameter */ double * average_1( input_data *input, CLIENT *client) /* input is parameters were marshaled by generated routine */ /* a pointer to a double, set to beginning of data array */ double *dp = input->input_data.input_data_val; u_int i; sum_avg = 0; for( i = 1; i <= input->input_data.input_data_len; i++ ) /* iterate over input */ sum_avg = sum_avg + *dp; /* add what ptrs points to ( '*' gets content ) */ dp++; sum_avg = sum_avg / input->input_data.input_data_len; return( &sum_avg ); /* end average_1 */ /* next is routine called from stub generated by rpcgen */ avg_proc.c : Server Program (1) #include <rpc/rpc.h> #include "avg.h /* avg.h generated rpcgen */ #include <stdio.h> /* run locally on '' called by a remote client. */ static double sum_avg; /* routine notice the _1 the version number and notice the client handle, not used here, but * still needs to be a parameter */ double * average_1( input_data *input, CLIENT *client) /* input is parameters were marshaled by generated routine */ /* a pointer to a double, set to beginning of data array */ double *dp = input->input_data.input_data_val; u_int i; sum_avg = 0; for( i = 1; i <= input->input_data.input_data_len; i++ ) /* iterate over input */ sum_avg = sum_avg + *dp; /* add what ptrs points to ( '*' gets content ) */ dp++; avg_proc.c : Server Program (2) /* * stub 'average_1_svc function handle called in avg_svc that was * generated by rpcgen * FYI: * result = (*local)((char *)&argument, rqstp); * where local is (char *(*)(char *, struct svc_req *)) average_1_svc; */ double * average_1_svc(input_data *input, struct svc_req *svc) CLIENT *client; return( average_1( input, client) ); sum_avg = sum_avg / input->input_data.input_data_len; return( &sum_avg ); /* end average_1 */ /* next is routine called from stub generated by rpcgen */

Compilation on client Compilation on rpcgen avg.x # generates: rpcgen avg.x # generates: # avg_clnt.c, avg_svc.c, avg_xdr.c, avg.h # avg_clnt.c, avg_svc.c, avg_xdr.c, avg.h gcc ravg.c c # -c generates.o files gcc avg_proc.c c gcc avg_clnt.c c gcc avg_svc.c c gcc avg_xdr.c c gcc o avg_svc avg_proc.o avg_svc.o avg_xdr.o -lnsl gcc c ravg ravg.o avg_clnt.o avg_xdr.o -lnsl 21 22.rhost Running Directly under your home directory on each machine (client and ) create a file named: maria:herc avg_svc.rhost maria:odin ravg atlas.cs.uga.edu 1 2 3 4 5 Add two or more lines in the format: <machine_name> <loginname> For example I added 3 lines: odin maria herc maria atlas maria 23 24

See Textbook i.e., reading assignment Resources Remote Method Invocation 1. http://www.cs.cf.ac.uk/dave/c/node34.html (RPCgen) 2. http://www.cs.cf.ac.uk/dave/c/node27.html (Sh. Mem) 3. http://www.linuxjournal.com/article/2204?page=0,2 4. https://beej.us/guide/bgipc/output/html/singlepage/ bgipc.html (1) Nice tutorial on RPC Remote Method Invocation (RMI) is a Java mechanism similar to RPCs. RMI allows a Java program on one machine to invoke a method on a remote object. Possible to Pass Objects( remote, local) as parameters to remote methods (via serialization). (2) (2) Shared Memorh (3) Linux journal tutorial uses avg.x (4) Beej s Guide 25 26 Marshalling Parameters Client invoke method: somemethod on a remote object Server 27