CS604 Assignment 1 Solution Spring 2017

CS604 Assignment 1 Solution Spring 2017

Assignment No. 01
Semester: Spring 2017
Question#1: [05 Marks]
Being an end user and an administration of any system, there are some privileges that have been given to you, suppose you are going to take the initial test as an operating system developer then specify which of the following instructions should be “Privileged” and “Non- Privileged”?
Instructions Name                       Privileged Or Non-Privileged
Clear memory
Turn off interrupts
Issue trap instructions
System Call
Access I/O Instructions
Question 2: [05 Marks]
Categorize the following examples into some events that cause the kernel code to invoke in order to manage computer resources (like I/O devices, memory and storage management) and control user programs to prevent errors and improper use of a computer system. That event could be an Interrupt, signal and trap:
1. Ahmad write a code in c language, like a=b/0.
2. Ayesha is compiling a C program an error occurs Invalid memory access or buffer overflow.
3. While running a program, you press <Ctrl-C>.
4. Yasir is typing Alphabets in notepad by hitting keystroke.
5. Bilal opening a folder from desktop by double clicking mouse.
Question 3: [10 Marks]
Understand the below program carefully and explain each line accordingly.
#include <stdio.h>
void main ( )
1………………… {
2……………………….int pid, status;
3……………………….pid = fork ( );
4……………………….if (pid = = -1)
5……………………… {
6……………………………printf(“fork failed\n”);
7……………………………exit(1) ;
8……………………….}
9………………………if (pid = = 0)
10……………………… {
11………………………… printf( “Child here ! \n”);
12………………………… exit (0);
13……………………….}
14……………………….else
15……………………… {
16………………………… wait (&status);
17………………………… printf(“well done kid !\n”);
18………………………… exit (0);
19……………………….}

Solution :

Question#1: [05 Marks]

Being an end user and an administration of any system, there are some privileges that have been given to you, suppose you are going to take the initial test as an operating system developer then specify which of the following instructions should be “Privileged” and “Non- Privileged”?

Answer:

The following operations need to be privileged: clear memory, turn off interrupts, access I/O Instructions. The rest can be performed in user mode.

  Name Privileged Non-Privileged
 Clear memory Clear Memory  
Turn off interrupts Turn off Interrupts  
 Issue trap instructions    Issue trap instructions
 System Call    System Call
 Access I/O Instructions Access I/O call  

Explanation:

Which of the following instructions should be privileged? why or why not

Turn off interrupts

Privileged so that a process cannot monopolize the CPU

Solution 2 :

DOWNLOAD SOLUTION HERE
loading...
  • aftab

    thanx my dear brother