chapter 3 processes outline
play

Chapter 3: Processes: Outline Process Concept: views of a process - PowerPoint PPT Presentation

Chapter 3: Processes: Outline Process Concept: views of a process Process Scheduling Operating Systems Operations on Processes Cooperating Processes Inter Process Communication (IPC) RPC: Processes Local Pipe


  1. Chapter 3: Processes: Outline • Process Concept: views of a process • Process Scheduling 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, Maria Hybinette, UGA Maria Hybinette, UGA Maria Hybinette, UGA Maria Hybinette, UGA Client-Server Remote Machine Remote Procedure Calls (RPC) Communication Mechanisms • Inter-machine process to process communication • Socket communication (Possible bonus project) – (abstract) procedure calls across a network: • Remote Procedure Calls (Project due next – FunctionCall [address] [ parameters] week). – Address – machine [& port] • Remote Method Invocation (Briefly, on your own) – rusers, rstat, rlogin, rup => daemons at ports • Registered library calls (port mapper) • Many are now disabled due to security concerns ( here ) – Hides message passing I/O from programmer • Looks (almost) like a procedure call -- but client invokes a procedure on a server. – Pass arguments – get results – Fits into high-level programming language constructs – Well understood Maria Hybinette, UGA Maria Hybinette, UGA Maria Hybinette, UGA Maria Hybinette, UGA

  2. rlogin [nike.cs.uga.edu:513] Address: IP_number[:Port_number] • Iden3fies the ul#mate des#na#on Secure shell/file(ssh, sLp, scp), • Problems: Passwords • IP addresses iden3fy hosts 22 Mail (SMTP) transmiMed unencrypted. WWW 25 – 127.0.0.1, 172.20.10.15, 128.192.101.135 • .rlogin/.rhosts files Echo 80 – {ingrid:509} nslookup nike.cs.uga.edu – Allow logins without a password 7 – ifconfig • Host has many applica3ons à rlogin 513 ports • Ports (16-bit iden3fier) 1-65,535 (about 2000 are reserved). Well-known 1-1,023 Registered 1,024-49,151 Dynamic 49,152-65,535 https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers Maria Hybinette, UGA Maria Hybinette, UGA Maria Hybinette, UGA Maria Hybinette, UGA RPC Calls : Portmapper Remote Procedure Calls (RPC) • RPC applica3ons picks any available port then • RPC High level view: registers with a portmapper daemon – Calling process attempt to call a � remote � routine on server – Calling process (client) is suspended – Parameters are passed across network to a process server – Server executes procedure – Return results across network – Calling process resumes Maria Hybinette, UGA Maria Hybinette, UGA Maria Hybinette, UGA Maria Hybinette, UGA

  3. Association 5 tuple {protocol, local-address, local-process, foreign-address, foreign-process} Remote Procedure Calls Client/Server Model Using RPC XDR pack XDR unpack Each RPC parameters • Usually built on top sockets (UDP) parameters call invocation by a call • stubs – client-side proxy for the actual procedure client process calls client server client on the server. server stub a client stub , stub • The client-side stub locates the server and which builds a return return unpack pack marshalls the parameters. message and results results • The server-side stub receives this message, sends it to a server kernel kernel stub unpacks the ‘marshalled’ parameters, and then performs the procedure call on the server. network • The server stub uses the message to generate a local procedure call to the server • If the local procedure call returns a value, the server stub builds a message and sends it to the client stub, which receives it and returns the result(s) to the client Maria Hybinette, UGA Maria Hybinette, UGA Maria Hybinette, UGA Maria Hybinette, UGA RPC Association Between Binding Machines Registration data flow • Association between remote and local host Client Process Portmapper – 5 tuple Procedure Call data flow • {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 Server Process • Local/foreign process: Typically the port number (not PID) • RPC application is packed into a program and is assigned an identifier (Port) • Portmap : allocate port numbers for RPC programs Maria Hybinette, UGA Maria Hybinette, UGA Maria Hybinette, UGA Maria Hybinette, UGA

  4. Execution of RPC Remote Procedure Calls • Machine independent representation of data: – Differ if most [or 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) Maria Hybinette, UGA Maria Hybinette, UGA Maria Hybinette, UGA Maria Hybinette, UGA Hide Complexity Tutorial ( linux journal ) Program to generate code • rpcgen generates C code from a file written in • rpcgen generates C code from a file written in � RPC language ��� <name>. x , e.g., avg.x � RPC language �� avoids programmer to worry about networking details Default output rpcgen Syntax Example – Stylistics – end with an X. <name>.x , e.g., avg.x Header file <name>.h avg.h – rpcgen avg.x XDR data type translate <name>_xdr.c avg._xdr.c • Leaves the programmer with 3 tasks: routines (from type in .h file) – avg.x stub program for server <name>_svc.c avg_svc.c – Create Client routine (main program on local host), then run it. • ravg <host> <parameters> stub program for client <name>_clnt.c avg_clnt.c • ravg localhost 1 2 3 4 • ravg vcf4 1 2 3 4 • (Create these) Application programmer (you) write • ravg vcf4 $RANDOM $RANDOM – Create Server program (e.g., actual code to compute something, e.g., an average), then run code for: it: • avg_proc & – Client routine (main program) • rpcinfo –p localhost • ravg <host> <parameters> – Server program (e.g., actual code to compute average) https://docs.oracle.com/cd/E19683-01/816-1435/rpcgenpguide-21470/index.html • avg_proc.c http://www.linuxjournal.com/article/2204?page=0,1 Maria Hybinette, UGA Maria Hybinette, UGA Maria Hybinette, UGA Maria Hybinette, UGA

  5. Application Routines of Interest avg.x : RPC language file • Server Routine: const MAXAVGSIZE = 200; struct input_data – average_1_svc (input_data, ): { • A avg_proc.c routine that is called from the server stub that was double input_data<200>; generated by rpcgen }; • Client Routine: typedef struct input_data input_data; – average_prog_1() • Local routine that parse parameter and that ultimately calls a � local � program AVERAGEPROG { average_1 routine from generated code in avg_clnt.c that packs version AVERAGEVERS { parameters (also uses routines in avg_xdr.c and sends code to double AVERAGE(input_data) = 1; server. } = 1; /* version */ } = 22855; /* � port number � */ Maria Hybinette, UGA Maria Hybinette, UGA Maria Hybinette, UGA Maria Hybinette, UGA ravg.c : Client Program(1) ravg.c : Client Program (2) /* client code - calls client stub, xdr client, xdr xerver, server stub, server routine */ /* clnt_create( host, program, version, protocol) #include "avg.h" /* header file generated by rpcgen */ * generic client create routine from rpc library #include <stdlib.h> * 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" ); { if (clnt == NULL) CLIENT *clnt; /* client handle, rpc.h */ { clnt_pcreateerror( host ); /* rpc error library */ double f, :*result_1, *dp, exit(1); char *endptr; } 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 */ * so AVERAGEPROG, VERSION */ average_1_arg.input_data.input_data_len = argc - 2; /* set number of items */ 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; clnt_destroy( clnt ); dp++; printf( "average = %e\n",*result_1 ); } } /* end average_1 prodedure */ /* next slide main() */

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend