Operating systems 3 processes
This presentation is the property of its rightful owner.
Sponsored Links
1 / 8

Operating Systems 3 - Processes PowerPoint PPT Presentation


  • 75 Views
  • Uploaded on
  • Presentation posted in: General

Operating Systems 3 - Processes. PIETER HARTEL. Principle of concurrency - giving a process the illusion that it owns the whole machine. A process has: Identifier Priority Program State + Control (what?). Process switch. User mode ↔ Kernel mode Synchronous: System call

Download Presentation

Operating Systems 3 - Processes

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Operating systems 3 processes

Operating Systems 3 - Processes

PIETER HARTEL


Principle of concurrency giving a process the illusion that it owns the whole machine

Principle of concurrency -giving a process the illusion that it owns the whole machine

  • A process has:

    • Identifier

    • Priority

    • Program

    • State + Control (what?)


Process switch

Process switch

  • User mode ↔ Kernel mode

    • Synchronous: System call

    • Asynchronous: Interrupt


Unix process creation example

UNIX process creation example

#include <stdio.h>

#include <stdlib.h>

#include <unistd.h>

#include <wait.h>

int main(intargc, char *argv[]) {

pid_tpid=fork();

printf("%s\n", argv[0]);

if (pid==0) { /* child process */

static char *argv[]={"echo","Foo",NULL};

execv("/bin/echo",argv);

exit(127); /* only if execv fails */

} else { /* pid!=0; parent process */

waitpid(pid,0,0); /* wait for child exit */

}

return 0;

}

  • Output?

  • gccFork.c

  • strace ./a.out

  • strace -f ./a.out

  • Which system call?


Process creation in the shell

Process creation in the shell


Unix signal example

UNIX signal example

#include <stdio.h>

#include <stdlib.h>

#include <signal.h>

void sigsegv_handler(int sig) {

printf("SIGSEGV received.\n");

exit(0);

}

int main() {

int *null_pointer=(int *)NULL;

signal(SIGSEGV,sigsegv_handler);

printf("About to segfault:\n");

*null_pointer=0;

printf("Why didn't we crash?\n");

return 1;

}

  • Output?

  • gcc Signal.c

  • ./a.out


More realistic state diagram queue

More realistic state diagram & queue

  • Pre-emption

  • Round-robin scheduling

  • Swapping


Summary

Summary

  • Principle of concurrency

  • A process is code+data+state

  • Management involves creation, switching and termination

  • Signals can be used between processes


  • Login