Title: Passing of Parameters As A Table
1Passing of Parameters As A Table
2System Call Memory Map
3Types of System Calls
- Process control
- File management
- Device management
- Information maintenance
- Communications
4Types of System Calls
- Process control
- Call Description
- pidfork() Create a child process
identical to parent - pidwaitpid(pid, statloc, options) Wait for
child to terminate - sexecve(name, argv, environp) Replace a
process core image - exit(status) Terminate proc execution
return status
5Types of System Calls
- File Management
- Call Description
- fdopen(file, .) Open file for read,
write, or both - sclose(fd) Close an open file
- nread(fd, buf, nbytes) Read
data from file to buffer - nwrite(fd, buf, nbytes) Write
data from buffer to file - poslseek(fd, offset, whence) Move
file pointer to . - sstat(name, buf) Write data
from buffer to file
6Types of System Calls
- Directory and File System Management
- Call Description
- smkdir(name, mode) Create a new
directory - srmdir(name, mode) Remove an empty
directory - slink(name1, name2) Create new
entry name2, pointing to name1 - sunlink(name)
Remove a directory entry -
- smount(special, name, flag) Mount a
file system - sumount(special)
Unmount a file system
7UNIX vs Win System Calls
- UNIX
- - One-to-one relationship between system calls
(e.g., read) - and library procedures (e.g., read) to invoke
system calls. - i.e., for each syscall ? roughly one library
procedure that is - called to execute it.
- Windows
- - radically different.
- - library calls and syscalls are highly
decoupled. - - Win32 API defined for programmers to use to
get OS services. - - Supported on all versions of Windows since
Win95. - - Difficult to distinguish kernel syscall and
user(-space) library - calls
8UNIX vs Win System Calls
9MS-DOS Execution
At System Start-up
Running a Program
10UNIX Running Multiple Programs
11Communication Models
- Communication may take place using either message
passing or shared memory.
Shared Memory
Msg Passing
12System Programs
- provide a convenient environment for program
development and execution. The can be divided
into - File manipulation
- Status information
- File modification
- Programming language support
- Program loading and execution
- Communications
- Application programs
- Most users view of the operation system is
defined by system programs, not the actual system
calls.
13MS-DOS System Structure
- MS-DOS written to provide the most
functionality in the least space - not divided into modules
- Although MS-DOS has some structure, its
interfaces and levels of functionality are not
well-separated
14MS-DOS Layer Structure
15UNIX System Structure
- UNIX
- limited by hardware functionality
- - the original UNIX operating system had
limited - structuring.
- - the UNIX OS consists of two separable parts.
- ? Systems programs
16UNIX System Structure
- ? The kernel
- Consists of everything below the system-call
interface and above the physical hardware - Provides the file system, CPU scheduling, memory
management, and other operating-system functions
a large number of functions for one level.
17UNIX System Structure
18Layered Approach
- the OS is divided into a number of layers
(levels), each built on top of lower layers. - - the bottom layer (layer 0) is the hardware
- - the highest (layer N) is the user interface.
- With modularity, layers are selected such that
each uses functions (operations) and services of
only lower-level layers.
19An Operating System Layer
20OS/2 Layer Structure
21Microkernel System Structure
- Moves as much from the kernel into user space.
- Communication takes place between user modules
using message passing. - Benefits
- - easier to extend a microkernel
- - easier to port the operating system to new
architectures - - more reliable (less code is running in kernel
mode) - - more secure
22Windows NT Client-Server Structure
23Virtual Machines
- A virtual machine takes the layered approach to
its logical conclusion. - It treats hardware and the operating system
kernel as though they were all hardware. - It provides an interface identical to the
underlying bare hardware. - The OS creates the illusion of multiple
processes, each executing on its own processor
with its own (virtual) memory.
24Virtual Machines (Cont.)
- The resources of the physical computer are shared
to create the virtual machines. - CPU scheduling can create the appearance that
users have their own processor. - Spooling and a file system can provide virtual
card readers and virtual line printers. - A normal user time-sharing terminal serves as the
virtual machine operators console.
25System Models
Non-virtual Machine
Virtual Machine
26VM Advantages/Disadvantages
- provides complete protection of system resources
since each VM is isolated from all other VMs. - ? isolation permits no direct sharing of
resources. - perfect vehicle for OS RD. System development
is done on the VM, instead of on a physical
machine - ? does not disrupt normal system operation.
27VM Advantages/Disadvantages
- VM concept is difficult to implement due to the
effort required to provide an exact duplicate to
the underlying machine.
28Java Virtual Machine
- Compiled Java programs are platform-neutral
bytecodes executed by a Java Virtual Machine
(JVM). - JVM consists of
- - class loader
- - class verifier
- - runtime interpreter
- Just-In-Time (JIT) compilers increase performance
29Java Virtual Machine
30System Design Goals
- User goals
- OS should be convenient to use, easy to
- learn, reliable, safe, and fast.
- System goals
- OS should be easy to design, implement, and
- maintain, as well as flexible, reliable,
error- - free, and efficient.
31Mechanisms and Policies
- Mechanisms determine how to do something,
policies decide what will be done. - The separation of policy from mechanism is a very
important principle - ? allows maximum flexibility if policy
- decisions are to be changed later.
32System Implementation
- Traditionally written in assembly language.
- OS can now be written in higher-level languages.
- Code written in a high-level language
- can be written faster.
- is more compact.
- is easier to understand and debug.
- An operating system is far easier to port (move
to some other hardware) if it is written in a
high-level language.
33System Generation (SYSGEN)
- OSs are designed to run on any of a class of
machines ? system must be configured for each
specific computer - site.
- SYSGEN program obtains information concerning the
specific configuration of the hardware system. - Booting starting a computer by loading the
kernel. - Bootstrap program code stored in ROM that is
able to locate the kernel, load it into memory,
and start its execution.
34Units - Orders of Magnitude
- kilo (103) milli (10-3)
- mega (106) micro (10-6)
- giga (109) nano (10-9)
- tera (1012) pico (10-12)
- peta (1015) femto (10-15)
- exa (1018) atto (10-18)
35Units - Orders of Magnitude
36Units - Orders of Magnitude
37Units - Orders of Magnitude
38Processes
- Process Concept
- Process Scheduling
- Operations on Processes
- Cooperating Processes
- Interprocess Communication
- Communication in Client-Server Systems
39Process Concept
- An OS executes a variety of programs
- Batch system jobs
- Time-shared systems user programs or tasks
- Terms job and process interchangeably.
- Process a program in execution process
execution must progress in sequential fashion. - A process includes
- program counter
- stack
- data section
40Process State
- As a process executes, it changes state
- new The process is being created.
- running Instructions are being executed.
- waiting The process is waiting for some event
to occur. - ready The process is waiting to be assigned to
a CPU. - terminated The process has finished execution.
41Diagram of Process State
42Process Control Block (PCB)
- Information associated with each process.
- Process state
- Program counter
- CPU registers
- CPU scheduling information
- Memory-management information
- Accounting information
- I/O status information
43Process Control Block (PCB)
44CPU Switch From Process to Process
45Process Scheduling Queues
- Job queue
- set of all processes in the system.
- Ready queue
- set of all processes residing in main memory,
- ready and waiting to execute.
- Device queues
- set of processes waiting for an I/O device.
- Process migration between the various queues.
46Ready Various I/O Device Queues
47Process Scheduling
48Schedulers
- Long-term scheduler (or job scheduler)
- selects which processes should be brought
- into the ready queue.
- Short-term scheduler (or CPU scheduler)
- selects which process should be executed
- next and allocates CPU.
49Addition of Medium Term Scheduling
50Schedulers (Cont.)
- Short-term scheduler is invoked frequently (ms)
- ? (must be fast).
- Long-term scheduler is invoked infrequently
(seconds, minutes) - ? (may be slow).
51Schedulers (Cont.)
- The long-term scheduler controls the degree of
multiprogramming. - Processes can be described as either
- ?I/O-bound process
- spends more time doing I/O than computations,
- many short CPU bursts.
- ? CPU-bound process
- spends more time doing computations few very
- long CPU bursts.
52Context Switch
- When CPU switches to another process
- - must save the state of the old process
- - load the saved state for the new process.
- Context-switch time is overhead the system does
no useful work while switching. - Time dependent on hardware support.
53Process Creation
- Parent process create children processes, which,
in turn create other processes, forming a tree of
processes. - Resource sharing
- Parent and children share all resources.
- Children share subset of parents resources.
- Parent and child share no resources.
- Execution
- Parent and children execute concurrently.
- Parent waits until children terminate.
54Process Creation (Cont.)
- Address space
- Child duplicate of parent.
- Child has a program loaded into it.
- UNIX examples
- fork system call creates new process
- exec system call used after a fork to replace the
process memory space with a new program.
55Processes Tree on UNIX
56Process Termination
- Process executes last statement and asks the
- to decide it (exit).
- Output data from child to parent (via wait).
- Process resources are deallocated by operating
system.
57Process Termination
- Parent may terminate execution of children
- processes (abort).
- Child has exceeded allocated resources.
- Task assigned to child is no longer required.
- Parent is exiting.
- OS does not allow child to continue if its parent
terminates. - Cascading termination.
58Cooperating Processes
- Independent process cannot affect or be affected
by the execution of another process. - Cooperating process can affect or be affected by
the execution of another process - Advantages of process cooperation
- Information sharing
- Computation speed-up
- Modularity
- Convenience
59Producer-Consumer Problem
- Paradigm for cooperating processes
- - producer process produces information
- - consumed by a consumer process.
- Cases
- unbounded-buffer places no practical limit on the
size of the buffer. - bounded-buffer assumes that there is a fixed
buffer size.
60Bounded-Buffer Shared-Memory Solution
- Shared data
- define BUFFER_SIZE 10
- Typedef struct
- . . .
- item
- item bufferBUFFER_SIZE
- int in 0
- int out 0
- Solution is correct, but can only use
BUFFER_SIZE-1 elements
61Bounded-Buffer Producer Process
- item nextProduced
- while (1)
- while (((in 1) BUFFER_SIZE) out) / do
nothing / - bufferin nextProduced
- in (in 1) BUFFER_SIZE
-
62Bounded-Buffer Consumer Process
- item nextConsumed
- while (1)
- while (in out) / do nothing /
- nextConsumed bufferout
- out (out 1) BUFFER_SIZE
63Interprocess Communication (IPC)
- Mechanism for processes to communicate and to
synchronize their actions. - Message system
- processes communicate with each other
- without resorting to shared variables.
- IPC facility provides two operations
- send(message) message size fixed or variable
- receive(message)
64Interprocess Communication (IPC)
- If P and Q wish to communicate, they need to
- establish a communication link between them
- exchange messages via send/receive
- Implementation of communication link
- physical (e.g., shared memory, hardware bus)
- logical (e.g., logical properties)
65Implementation Questions
- How are links established?
- Can a link be associated with more than two
processes? - How many links can there be between every pair of
communicating processes? - What is the capacity of a link?
- Is the size of a message that the link can
accommodate fixed or variable? - Is a link unidirectional or bi-directional?
66Direct Communication
- Processes must name each other explicitly
- send (P, message) send a message to process P
- receive(Q, message) receive a message from
process Q - Properties of communication link
- Links are established automatically.
- A link is associated with exactly one pair of
communicating processes. - Between each pair there exists exactly one link.
- The link may be unidirectional, but is usually
bi-directional.
67Indirect Communication
- Messages are directed and received from mailboxes
(also referred to as ports). - Each mailbox has a unique id.
- Processes can communicate only if they share a
mailbox.
68Indirect Communication
- Properties of communication link
- Link established only if processes share a common
mailbox - A link may be associated with many processes.
- Each pair of processes may share several
communication links. - Link may be unidirectional or bi-directional.
69Indirect Communication
- Operations
- create a new mailbox
- send and receive messages through mailbox
- destroy a mailbox
- Primitives are defined as
- send(A, message)
- send a message to mailbox A
- receive(A, message)
- receive a message from mailbox A
70Indirect Communication
- Mailbox sharing
- P1, P2, and P3 share mailbox A.
- P1, sends P2 and P3 receive.
- Who gets the message?
- Solutions
- Allow a link to be associated with at most two
processes. - Allow only one process at a time to execute a
receive operation. - Allow the system to select arbitrarily the
receiver. Sender is notified who the receiver
was.
71Synchronization
- Message passing may be either blocking or
non-blocking. - Blocking is considered synchronous
- Non-blocking is considered asynchronous
- send and receive primitives may be either
blocking or non-blocking.
72Buffering
- Queue of messages attached to the link
implemented in one of three ways. - 1. Zero capacity 0 messagesSender must wait
for receiver (rendezvous). - 2. Bounded capacity finite length of n
messagesSender must wait if link full. - 3. Unbounded capacity infinite length Sender
never waits.
73Client-Server Communication
- Sockets
- Remote Procedure Calls
- Remote Method Invocation (Java)
74Sockets
- A socket is defined as an endpoint for
communication. - Concatenation of IP address and port
- The socket 161.25.19.81625 refers to port 1625
on host 161.25.19.8 - Communication consists between a pair of sockets.
75Socket Communication
76Remote Procedure Calls (RPC)
- RPC abstracts procedure calls between processes
on networked systems. - Stubs client-side proxy for the actual
procedure on the server. - The client-side stub locates the server and
marshalls the parameters. - The server-side stub receives this message,
unpacks the marshalled parameters, and performs
the procedure on the server.
77Marshalling Parameters
78Execution of RPC
79Remote Method Invocation (RMI)
- Remote Method Invocation (RMI) is a Java
mechanism similar to RPCs. - RMI allows a Java program on one machine to
invoke a method on a remote object.
80Sought-out Specialties 2004
Specialty of 1400 CIOs surveyed Application
development 18 Networking 13 Help
desk 12 Internet development 9 DB
management 8 Project management
8 Info security 7
81High-Demand Skills
Skills Windows
Administration 82 SQL Server Admin 56 CISCO
Network admin 38 VB development 37 Check
Point Firewall admin 32 ASP development
27 XML development 19 Linux
admin 16 Java development 15 .Net
development 14 Oracle development 13 Active X
development 11