30
Process management in Min ix 1 Processes • Process is a program in execution. • Program is a static entity while process is an active entity. Process Control Block (PCB) is a data structure that holds essential process information. Process table is and array or link list of PCBs.

Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

  • View
    225

  • Download
    3

Embed Size (px)

Citation preview

Page 1: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 1

Processes

• Process is a program in execution.

• Program is a static entity while process is an active entity.

• Process Control Block (PCB) is a data structure that holds essential process information.

• Process table is and array or link list of PCBs.

Page 2: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 2

The Internal Structure of Minix

• Minix is structured in four layers.

User processes (Init)

Server processes (MM, FS)

I/O tasks and system task (Disk task)

Process management

Page 3: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 3

Process Management

• Bottom layer of the structure.

• Catches hardware interrupts and software traps.

• Performs scheduling.

• Handles messages between processes (checks for protection, locates send and receive buffers, copies messages between senders and receiver’s buffers.)

Page 4: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 4

I/O Tasks (Drivers)

• Second layer from the bottom.

• There is one task per device type.

• Example of tasks are:disk tasks, printer tasks, terminal tasks, etc..

• There is one special task: system task. System task provides for communication of MM and FS with the kernel and its data structures.

Page 5: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 5

The Kernel

• The layer 1 and 2 code (the process management code and the tasks) are linked together into a single binary program called the kernel.

Page 6: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 6

Server Processes

• Third layer from the bottom.

• Provide useful services to the user processes such as MM (Memory Management) and FS (File system).

• Less privileged than the process management and the tasks

Page 7: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 7

Memory Manager

• Memory manager carries out all the Minix system calls that involve memory management.

• E.g.• FORK

• EXEC

• BRK

Page 8: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 8

File System

• File system carries out all the Minix file system calls.

• E.g.• READ/WRITE

• MOUNT

• CHDIR

Page 9: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 9

Servers As User Processes

• Servers run at the same privilege level as user processes but at higher priority.

• Q: What is the difference between the privilege and priority?

Page 10: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 10

Server’s Characteristics• They start when the system starts.

• They never terminate when the system is active.

• To accommodate a new server the kernel must be recompiled.

• The kernel startup code installs the servers in the higher priority slots of process table before any user processes are allowed to run.

Page 11: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 11

Processes Management in Minix

• All user processes in the system are descendants of a process called init.

• The Minix boot program loads into memory:

• the kernel

• the memory nanager

• the fisle syetm

• and init (the first user process)

Page 12: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 12

Init execution steps• Init executes the following steps:

– reads the file /etc/ttytab to find all potential login terminals

– forks off a child process for each terminal– each child executes usr/bin/getty which prints a

message and waits for a name to be typed– usr/bin/login is called with the name as its

argument– after a successful login /bin/login executes user’s

shell specifies in etc/passwd file.

Page 13: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 13

Interprocess Communication

• Processes communicate in Minix via message passing.

• Three primivites are provided for sending and receiving messages:– send (dest, &message)– receive(source, &message)– send_rec(src_dst, &message)

Page 14: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 14

Send

• send (dest, &message)

• Is used to send a message to process dest.

• The second parameter: &message is the address of the message data.

Page 15: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 15

Receive

• receive(source, &message)

• Is used to receive a message from process source.

• The second parameter: &message is the address of the message data to be received.

Page 16: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 16

Send and Receive

• send_rec(src_dst, &message)

• Is used to send a message and wait for a reply form the same process.

• The replay overwrites the original message.

Page 17: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 17

Synchronous and Asynchronous Message Passing

• When a process sends a message to a process that is not currently waiting to receive the message, the sender blocks until the destination does RECEIVE.

• Q. WHY?

• Q. What is the difference between synchronous and asynchronous message

passing?

Page 18: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 18

Process Scheduling in Minix

• Minix uses multilevel queue scheduling algorithm.

• There are three levels corresponding to layers 2, 3 and 4 of the Minix structure

• Tasks and server processes run until they block (FCFS).

• User processes use Round Robin with quantum 100 msec.

Page 19: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 19

Minix Source Code Organization

• Source code is organized in two directories: /usr/include and usr/src

• /usr/include directory contain:– sys/ : contains additional POSIX headers– minix/: includes header files used by Minix– ibm/: includes header files with IBM PC

specific definitions

Page 20: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 20

Src/ directory

• Scr/ directory contains:– kernel/ : layers 1 and 2 of Minix– mm/: the code for memory manager– fs/ : the code for the file system– lib/ : the source code for library procedures– tools/:the source code for the init program– boot/: the source code for booting and installing

Minix.

Page 21: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 21

Minix Executable

• When Minix is compiled all source codes in src/kernel/, src/mm/ and src/fs/ are compiled to object files. All the object files in src/kernel/ are linked together to form a single executable program, kernel. The object files in src/mm/ and in src/fs/ are linked respectively to form mm and fs.

Page 22: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 22

Process header files

• src/kernel/kernel.h– defines macros _POSIX SOURCE, _MINIX.

_SYSTEM– includes other header files– a lot of other files may share a large number of

definitions by including kernel.h

Page 23: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 23

• const.h– contains a number of machine dependent values

such as interrupt vectors– contains machine independent values such as

priorities of scheduling queues.

• type.h– defines several prototypes and structures used

in any implementation of Minix and some machine dependent values

Page 24: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 24

• proto.h– all functions that must be know outside of of

the file in which they are defined are in this file

• glo.h– all kernel global variables are defined here

Page 25: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 25

• Proc.h– defines a process table entry as proc.– Defines process table as

• proc[NR_TASKS+NR_PROCS]

• Question:– What are the values of NR_TASK and

NR_PROCS?– Look at include/minix/const.h and

include/minic/config.h

Page 26: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 26

• protect.h– defines values very specific to the protected

mode of the Intel Processor architectures.

Page 27: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 27

How to Backup the Kernel

– Login as bin– In bin’s home directory /usr/src do! cpdir kernel kernelBackup

Page 28: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 28

How To Restore the Kernel

! cpdir kernel_backup kernel! rm kernel/*.o! cd tools! make hdboot! shutdown

Page 29: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 29

How to Compile the Kernel

• Log in to as bin

• Change directory to tools

• Run make hdboot

Page 30: Process management in Minix1 Processes Process is a program in execution. Program is a static entity while process is an active entity. Process Control

Process management in Minix 30

How to boot from an older (correct) version of Minix).

• Use the “image” variable of the boot monitor.

• For example:– hd1> image=minix/2.0.0– hd1> boot

• After correcting the problem and recompiling the kernel you may instruct the monitor to pick the most recent version by typing.– Hd1> unset image– hd1> boot