> anishgoyal


NotesOperating System Concepts Essentials (Silberschatz) Lecture 3

Processes

calendar_today   article 6026 words   access_time 34 min   replay Modified

Table of Contents

Process Concept

The Process

process in memory

Process State

Process Control Block

process control block

Threads

Process Scheduling

Scheduling Queues

ready queue and device queue

process scheduling diagram

Schedulers

swapping process diagram

Context Switch

Process Operations

Process Creation

 1#include <sys/types.h>
 2#include <stdio.h>
 3#include <unistd.h>
 4
 5int main() {
 6
 7pid t pid;
 8
 9/* fork a child process */
10pid = fork();
11if (pid < 0) { /* error occurred */
12  fprintf(stderr, "Fork Failed");
13  return 1;
14}
15
16else if (pid == 0) { /* child process */
17  execlp("/bin/ls","ls",NULL);
18}
19
20else { /* parent process */
21  /* parent will wait for the child to complete */
22  wait(NULL);
23  printf("Child Complete");
24}
25
26return 0;
27}

Process Termination

Interprocess Communication

Shared-Memory Systems

Message-Passing Systems

Naming

Synchronization

Buffering

Examples of IPC Systems

Communication in Client-Server Systems

Sockets

 1import java.net.*;
 2import java.io.*;
 3
 4public class DateServer {
 5
 6public static void main(String[] args) {
 7try {
 8ServerSocket sock = new ServerSocket(6013);
 9
10/* now listen for connections */
11while (true) {
12Socket client = sock.accept();
13
14PrintWriter pout = new
15PrintWriter(client.getOutputStream(), true);
16
17/* write the Date to the socket */
18pout.println(new java.util.Date().toString());
19
20/* close the socket and resume */
21/* listening for connections */
22client.close();
23}
24}
25
26catch (IOException ioe) {
27System.err.println(ioe);
28}
29}
30}
 1import java.net.*;
 2import java.io.*;
 3
 4public class DateClient {
 5public static void main(String[] args) {
 6try {
 7
 8/* make connection to server socket */
 9Socket sock = new Socket("127.0.0.1",6013);
10
11InputStream in = sock.getInputStream();
12BufferedReader bin = new BufferedReader(new InputStreamReader(in));
13
14/* read the date from the socket */
15String line;
16while ( (line = bin.readLine()) != null)
17System.out.println(line);
18
19/* close the socket connection*/
20sock.close();
21}
22
23catch (IOException ioe) {
24System.err.println(ioe);
25}
26}
27}

Remote Procedure Calls

rpc execution

Pipes

Ordinary Pipes

pipe file descriptors

Named Pipes

References

Sources

Graph