Operating systems 3 processes
Download
1 / 8

Operating Systems 3 - Processes - PowerPoint PPT Presentation


  • 120 Views
  • Uploaded on

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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Operating Systems 3 - Processes' - clint


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

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?



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


ad