Understanding Advanced Operating Systems Concepts with Professor Banerjee

Slide Note
Embed
Share

Learn about the foundational concepts of Distributed Systems, Processes, Inter-process communication, and more in the Advanced Operating Systems course taught by Associate Professor Nilanjan Banerjee at the University of Maryland Baltimore County. Explore topics such as process execution, memory management, IPC mechanisms, and client-server architectures to build a strong understanding of operating systems principles.


Uploaded on Sep 27, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. CMSC621: Advanced Operating Systems Nilanjan Banerjee Associate Professor, University of Maryland Baltimore County nilanb@umbc.edu http://www.csee.umbc.edu/~nilanb/teaching/621/ Advanced Operating Systems 1

  2. Announcements TA office hours. 12:30 PM 2:30 PM (Wednesdays) 5:30 PM 7:30 PM (Thursdays) ITE 349 First quiz performance was very poor Retake the quiz after 2 weeks 2

  3. We will first learn the building blocks of Distributed Systems Processes (Assumption: You know how to create new processes in linux) Inter-process communication Named Pipes Shared Memory Signals Sockets Threads Thread creation/deletion/execution Mutual exclusion Conditional variables on locks Implementing client-server architecture of Distributed Systems Remote Procedure calls Remote Method Invocation Project 1 3

  4. But what is a process? An operating system executes a variety of programs: Batch system jobs Time-shared systems user programs or tasks Process a program in execution; process execution must progress in sequential fashion A process includes: program counter stack data section 4

  5. Process Memory looks like. virtual Address space why virtual? 5

  6. Inter-process communication Processes within a system may be independent or cooperating Cooperating process can affect or be affected by other processes, including sharing data Reasons for cooperating processes: Information sharing Computation speedup Convenience Cooperating processes need interprocess communication (IPC) 6

  7. IPC mechanisms Pipes (unidirectional) Anonymous pipes (must have seen in a OS course) Named pipes (FIFOs) (communication between processes that are not child and parent) (makes use of semaphores) Shared memory Share a chunk of memory for read/write between processes Mmaped files Communication through a file mapped to memory Message passing Network sockets Signals Slightly weird way of IPC 7

  8. Pipes (unidirectional data transfer) Anonymous pipes Defined within a process Communication between parent and child processes Named pipes (FIFO) Allows communication between processes which are not child/parent Linux utilty: mkfifo 8

  9. mkfifo int retval = mkfifo( pathto the pipe , permissions) Creates a pipe Use this pipe for reading writing, just like a file int fid = open( pathto file , O_RDWR); use read(fid, char *, length) and write(fid, char *, length) to read and write from the pipe 9

  10. Shared memory Shared memory Process 2 Process 1 Page table Page table physical memory Linux utilty: shmget, shmat, shmdt 10

  11. Shared memory POSIX Shared Memory Process first creates shared memory segment segment id = shmget(IPC PRIVATE, size, S IRUSR | S IWUSR); Process wanting access to that shared memory must attach to it shared memory = (char *) shmat(id, NULL, 0); Now the process could write to the shared memory sprintf(shared memory, "Writing to shared memory"); When done a process can detach the shared memory from its address space shmdt(shared memory); 11

  12. Memory mapped files (awesome hack!) Process 2 Process 1 File on disk File pages cached in memory Page cache Page table Page table Linux utility mmap() 12

  13. Mmap() First create a file of all zeros dd if=/dev/zero of= your file bs=1024 count = 1024 Creates a file of size 1M Open that file Memory map that file mmap(start_addr, length, protocol (PROT_READ|PROT_WRITE), flags (MAP_SHARED), <fd of the open file>, offset) Returns a pointer to read and write from the mmaped region 13

  14. POSIX Signals Linux kernel Process 1 Process 2 deliver a signal Register a signal Name SIGINT SIGQUIT SIGKILL SIGSEGV SIGPIPE SIGALRM SIGUSR1 SIGUSR2 Description Interrupt character typed terminate process Quit character typed (^\) create core image kill -9 Invalid memory reference create core image Write on pipe but no reader terminate process alarm()clock rings user-defined signal type terminate process user-defined signal type terminate process Default Action terminate process terminate process 14

  15. signals int kill( pid_t pid, int signo ); Send a signal to a process with a process id signal(<signal name>, <pointer to handler>) Handle a maskable signal in your code 15

  16. Short homework Assume that a mmapped file has four numbers (1) a (2) b (3) c (4) sum = a+b+c Three processes are executed. First process increments a Second process increments b Third process increments c Each time one of the above happens sum is updated Add proper mutual exclusion to ensure that sum is always equal to a+b+c. 16

  17. Message Passing Using Sockets A socket is defined as an endpoint for communication Concatenation of IP address and port The socket 161.25.19.8:1625 refers to port 1625 on host 161.25.19.8 Communication consists between a pair of sockets 17

  18. Message Passing Using Sockets 18

  19. Concept of Remote Procedure calls Remote procedure call (RPC) abstracts procedure calls between processes on networked systems Stubs client-side proxy for the actual procedure on the server The client-side stub locates the server and marshalls the parameters The server-side stub receives this message, unpacks the marshalled parameters, and performs the procedure on the server 19

  20. Execution of RPC

More Related Content