Alan Kaminsky Department of Computer Science Rochester Institute of Technology 4486 + 2220 = 6706
Home Page
Operating Systems I 4003-440-02 Winter Quarter 2012
Course Page

4003-440-02 Operating Systems I
Module 6. Process Programming -- Lecture Notes

Prof. Alan Kaminsky -- Winter Quarter 2012
Rochester Institute of Technology -- Department of Computer Science


The Unix Process API


Interprocess Communication/Synchronization With Pipes

  • File descriptors
    • File descriptor 0 = standard input
    • File descriptor 1 = standard output
    • File descriptor 2 = standard error

  • System calls and library routines (Linux)

  • Program pipedemo1 -- source code
    • Demonstrates pipe and fork

  • Program pipedemo2 -- source code
    • Demonstrates pipe, fork, dup, and exec


Interprocess Synchronization With Semaphores

  • System calls and library routines (Linux)
    • ipc -- Summary of IPC
    • semget -- Get or create semaphores
    • semop -- Acquire or release semaphores
    • semctl -- Initialize, remove, and do other things to semaphores

  • Other system calls and library routines (Linux)
    • signal -- Catch a signal
    • kill -- Send a signal to a process

  • Helpful commands (Linux)
    • ipcs -- Print status of IPC resources
    • ipcrm -- Remove IPC resources
    • kill -- Kill a process

  • Program dp1 -- source code
    Program philosopher1 -- source code
    • Demonstrates semaphores, signal, and kill


Interprocess Communication With Shared Memory

  • System calls and library routines (Linux)
    • ipc -- Summary of IPC
    • shmget -- Get or create shared memory segments
    • shmat, shmdt -- Attach or detach shared memory segments
    • shmctl -- Do various things to shared memory segments, such as remove them

  • Program pc1 -- source code
    Program consumer1 -- source code
    Program producer1 -- source code
    struct circbuf -- header file -- source code
    • Demonstrates shared memory, semaphores, signal, and kill

  • If you're going to do stuff with shared memory, it's easier to have multiple threads in one process


Interprocess Communication With Messages

  • System calls and library routines (Linux)
    • ipc -- Summary of IPC
    • msgget -- Get or create message queues
    • msgsnd, msgrcv -- Send or receive messages
    • msgctl -- Do various things to message queues, such as remove them

  • Demo programs TBD

  • If you're going to do stuff with interprocess messages, it's more flexible to use networking (TCP sockets, UDP datagrams)

Operating Systems I 4003-440-02 Winter Quarter 2012
Course Page
Alan Kaminsky Department of Computer Science Rochester Institute of Technology 4486 + 2220 = 6706
Home Page
Copyright © 2013 Alan Kaminsky. All rights reserved. Last updated 12-Jan-2013. Please send comments to ark­@­cs.rit.edu.