Computer Science 454 - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

Computer Science 454

Description:

Requires resources to be ... exec, execl, execv /*See the man page! ... use fork then exec() - how shell commands work. orphaned/zombie processes (later) ... – PowerPoint PPT presentation

Number of Views:89
Avg rating:3.0/5.0
Slides: 9
Provided by: csIas
Category:
Tags: computer | exec | science

less

Transcript and Presenter's Notes

Title: Computer Science 454


1
Computer Science 454
  • Processes In Xinu

2
Process vs. Program
  • process
  • dynamic
  • part of a program in execution.
  • a live entity, it can be created, executed, and
    terminated.
  • it goes trough different states
  • wait
  • running
  • ready, etc.
  • Requires resources to be allocates by the OS.
  • zero or more processes may executing the same
    code.
  • program
  • static
  • no states

3
Process creation, system calls and Context
Switching
  • getpid() /gets the current pid/
  • getppid() /gets the parent pid/
  • exec, execl, execv /See the man page!/
  • execl(/bin/ls, ls, -l, (char 0))
    /overlay original program
  • use fork then exec() - how shell commands work
  • orphaned/zombie processes (later)
  • XINU implements fork() as create() -(see man fork)
  • Context Switch
  • Saves current machine state
  • loads the next scheduled process
  • via interrupt, multiprogramming, etc.

4
Parent child processes
  • main()
  • int pid /hold process-id in parent/
  • printf(Just one process so far\n)
  • printf(Calling fork \n)
  • pid fork() / create new process /
  • if ( pid 0 )
  • printf( I am the child\n)
  • else if ( pid gt 0 )
  • printf( Im the parent, the child has pid
    d\n, pid)
  • else
  • printf( fork returned error code, no
    child\n)

5
fork() example
6
List and Queue manipulation
  • Important Constants
  • NSEM of semaphores
  • NQENT of entries in q array (see q.h on page
    58)
  • NPROC Max of processes a system can have.
  • List and Queue Processing
  • Doubly linked lists
  • head
  • tail
  • node
  • prevPtr
  • data
  • nextPtr

7
Queue Structure
Highest priority items at link next to tail.
(see page 62 in text) This is an array
implementation of a doubly linked list enqueue,
dequeue (see page 60 in text)
8
Implementation of Queue Array
  • Used to keep track of
  • Ready List
  • 2 entries
  • List for each Semaphore
  • 2NSEM
  • Sleep List
  • 2 entries
  • See page 57 in text
  • 42NSEM NPROC NQENT
Write a Comment
User Comments (0)
About PowerShow.com