Download Downlaod File

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

CP/M wikipedia , lookup

Copland (operating system) wikipedia , lookup

Distributed operating system wikipedia , lookup

VS/9 wikipedia , lookup

DNIX wikipedia , lookup

Burroughs MCP wikipedia , lookup

Process management (computing) wikipedia , lookup

Transcript
Operating Systems (Homework #2)
Dr.Majid Khan
Student: Sarah Tariq Bashawri
ID:#200800585
Due Date: 06-10-2012
NOTE: You need to submit a hand written solution for this homework which must be submitted
during the class time before the deadline.
Q1 (50) Please answer the following questions:
A: What is an interrupt vector? How do the interrupts work in a general purpose
computer system?
Interrupt vector, is what contains the addresses of all the service routines.




Hardware may trigger an interrupt at any time by sending a signal to the CPU, usually by
way of the system bus. Software may trigger an interrupt by executing a special
operation called a system call.
When the CPU is interrupted, it stops what it is doing and immediately
transfers execution to a fixed location.
The fixed location usually contains the starting address where the service routine for the
interrupt is located.
The interrupt service routine executes; on completion, the CPU resumes the interrupted
computation.
B: What is the difference between multi-programming and multi-tasking (time sharing)?
Multi-Programming
Its needed for efficiency.
Multiprogramming is the technique of running
several programs at a time using timesharing.
It allows a computer to do several things at
the same time.
Multiprogramming creates logical parallelism.
The concept of multiprogramming is that the
operating system keeps several jobs in
memory simultaneously.
The operating system selects a job from the
job pool and starts executing a job, when that
job needs to wait for any I/O operations the
CPU is switched to another job.
Multi-Tasking
Multitasking is the logical extension of
multiprogramming.
The concept of multitasking is quite similar to
multiprogramming but difference is that the
switching between jobs occurs so frequently
that the users can interact with each program
while it is running.
A time-shared operating system uses CPU
scheduling and multiprogramming to provide
each user with a small portion of time-shared
system.
The main idea here is that the CPU is never
idle.
C: What is Direct Memory access (DMA)? What are its benefits?
Method of transferring data from the computer's RAM to another part of the computer without
processing it using the CPU.
Benefits:
- CPU never stops executing its programs and DMA transfer is free in terms of time.
- Computer system performance is improved by direct transfer of data between memory and
I/O devices, bypassing the CPU.
- CPU is free to perform operations that do not use system buses.
D: What is a bootstrap program? What is its purpose?
In computers, to bootstrap is to load a program into a computer using a much smaller initial
program to load in the desired program (which is usually an operating system).
A technique by which a simple computer program activates a more complicated system of
programs.
Generally known as firmware
Purpose:
-Developing complex software systems by using simpler software.
E: What is the difference between symmetric and asymmetric multi-processing?
Symmetric
- Has multiple nodes running applications,
monitoring each other.
- All processors of symmetric multiprocessing
are peers.
- Each CPU in symmetric multiprocessing runs
the same copy of the OS
Asymmetric
-Has one machine in hot-standby mode.
-Relationship between processors of
asymmetric multiprocessing is a master-slave
relationship
-CPU in asymmetric multiprocessing split
copies of the OS responsibilities.
F: What is the difference between a program and a process?
Program
A program is a set of instructions that are to
perform a designated task.
Process
An operation which takes the given
instructions and perform the manipulations as
per the code, called ‘execution of instructions’
A process is entirely dependent of a ‘program’.
G: What is the difference between long term scheduler and short term scheduler?
Long- Term
Or job scheduler – selects which processes
should be brought from job queue
(maintained on disk) into the ready queue.
Short-Term
Or CPU scheduler – selects which process from
ready queue should be executed next and
allocates CPU.
H: What are process states? Where is the process state stored in the operating system?
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 processor
Terminated: The process
Process State is stored mostly in computer registers when the process is executing, and in
memory otherwise.
I: Why do we need queues for process scheduling? What queues are generally present in an
operating system?

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
We need queues because:
- A good mechanism where the relative importance of each process may be precisely
defined.
- Reduced dependency on component availability
- Shorter component lifetimes
- Uninterrupted productivity when using disconnected applications
- Message reliability
- Efficient server scheduling
J: What are the most common ways for inter-process communication in an operating system?
What are the advantages/disadvantages of each one of them?
Advantages
-
Disadvantages
Shared memory
- Programming for IPC becomes simple
in the sense that we simply write and
read to an address pointer available in
our process address space.
- We need not use system calls like
write and read.
- The updations to the kernel resident
shared memory object are done by the
kernel asynchronously.
- It saves lot of time compared to write
and read.
–  Must synchronize data accesses;
error prone.
-
-
Message passing
Makes sharing explicit
  Improves modularity
(narrow interface)
Does not require trust
between sender and receiver
Performance overhead to
copy messages
Q2 (40): Please draw the memory layout of all the processes created by running the following
program? Explicitly show all the memory regions (text, data, stack and heap) for each process
and display the variables and their respective values as stored in each region.
Also, what will be printed by this program on the screen?
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
void main() {
pid_t pid;
int k=100;
int m=200;
pid = fork();
if (pid==0) {
m=300;
int i=0;
while(i<10000) i++;
printf("child process:k=%d,m=%d\r\n",k,m);
pid = fork();
k++;
printf("child process:k=%d,m=%d\r\n",k,m);
}
else {
printf("parent process waiting for child ... \r\n");
wait(NULL);
printf("parent process:k=%d,l=%d\r\n",k,m);
}
}
Q3 (10): Please answer the question 3.11 from the textbook?
A=0
B = 2603
C = 2603
D = 2600