0% found this document useful (0 votes)
33 views17 pages

OS Assignments

This document contains an assignment on operating system concepts. It includes questions about computer system structure, operating system services, differences between user and kernel mode, interrupts and traps, storage systems from slowest to fastest, direct memory access advantages, multiprogramming advantages, system calls vs system programs, microkernel structure, bootstrap purpose, operating system services and advantages, storing the OS in firmware vs disk, system call categories, layered system design advantages, microkernel design advantages, shared file/device interfaces, process memory layout, process control block components, process states, process scheduling representation, and differences between shared memory and message passing models.

Uploaded by

Ahmed Sabry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views17 pages

OS Assignments

This document contains an assignment on operating system concepts. It includes questions about computer system structure, operating system services, differences between user and kernel mode, interrupts and traps, storage systems from slowest to fastest, direct memory access advantages, multiprogramming advantages, system calls vs system programs, microkernel structure, bootstrap purpose, operating system services and advantages, storing the OS in firmware vs disk, system call categories, layered system design advantages, microkernel design advantages, shared file/device interfaces, process memory layout, process control block components, process states, process scheduling representation, and differences between shared memory and message passing models.

Uploaded by

Ahmed Sabry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Name: Amar Zaky Nassar

Operating System
Assignments

‫دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة‬ Page 1
Assignment1

1) Explain using a diagram:


• Computer System Structure

• Interrupt-drive I/O Cycle

‫دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة‬ Page 2
• Computer Startup

• Transition from User to Kernel Mode

• View of Operating System Services

‫دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة‬ Page 3
2) What are the three main purposes of an operating system?

1- Resource Management or allocate

4- User Interface

5- System Security

3) What are the main differences between user mode and kernel mode?
Kernel mode User made
Access to resources Direct access to system Don’t have direct access to
resource system resource
Interruptions The whole operation system Only single process fails if
might go done if an interrupt an interrupt occur
occurs
Mode bit 0 1

4) What is the purpose of interrupts?


Interrupt is triggered by hardware device to allow the processor to execute the corresponding
interrupt handler routine.

How does an interrupt differ from a trap?


Trap is triggered by a user program to invoke OS functionality.

Interrupt is triggered by hardware device to allow the processor to execute the corresponding
interrupt handler routine.

5) Define the following terms


• Operating system:-
A program acts as an intermediary between the computer user and computer hardware.

• Kernel:-
Kernel is the one program running at all time on the computer.

‫دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة‬ Page 4
• System call:-
System call is a mechanism that provides the interface between a process and the OS.
• System program:-
System program provide a convenient (‫ )سهل‬environment for program development and execution.

• Application program:-
All program not associated with the OS.

• Middleware:-
A set of software frameworks that provide additional services to the application developers such as
database.

• Protection:-
Any mechanism for controlling access of processes or users to resources defined by the OS.

• Security:-
Defense of the system against internal and external attacks.

6) Rank the following storage systems from slowest to fastest:

(Hard - disk drives - Registers - Optical disk - Main memory - Nonvolatile memory -
Magnetic tapes - Cache)

1- Magnetic tapes
2- Optical disk
3- Disk drives
4- Nonvolatile memory
5- Main memory
6- Cache
7- Registers

7) What is the main advantage of using DMA (Direct memory access)?

‫دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة‬ Page 5
Lower CPU utilization (‫ )استخدام‬and faster data transfer.

8) What is the advantage of multiprogramming systems?


Multiprogramming system organizes jobs so CPU always has one job to execute, one job selected
and run via job scheduling.

9) Briefly explain
• The difference between a system call and a system program
System calls create an interface between the process and OS.
System program define the user inter face of the OS and create convenient environment for program
development and execution.

• The microkernel OS structure. *****************


Only the most important service are inside the kernel and the rest of OS services are present inside
the system program.

• The uses of a bootstrap program


Loads OS, initializes system and load applications.

10) What is the purpose of system calls?


A mechanism that provides the interface between a process and the OS.

11) What is the purpose of system programs?


It provides a suitable environment for the program development and execution.

12) List the services provided by an operating system and explain how each creates
convenience for users.

‫بقدملك انترفيس تشغل فيها البرامج الي بتاخد انبوت و تديك اوتبوت واوصللك كل ده ببعض‬
‫ بتاعة البرنامج والموارد بتاعة الجهاز‬s‫ولو في مشكلة هاحسبلك الخطاء فين واحميلك الملفات‬
1-user interface: GUI, CLI or batch.
2-program execution: provide a suitable environment to run any program.
3-I/O operation: help you using input and output devices.
4-file system manipulation: create and delete files and search them.
5-communication: communication via shared memory or over network.
6-error detection: tell me all information about any error occur.

‫دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة‬ Page 6
7- Resource allocation: ‫يوفر لي الموارد التي يحتاجدها كل برنامج‬
8- Accounting
9- Protect and security

13) Why do some systems store the operating system in firmware, while others store it on
disk?
Devices store OS in firmware for quick boot and security,
Or on disk for flexibility, larger storage, and ability to install multiple OS.
The decision depends on the system's requirements and constraints.

14) List out five categories of system calls


s‫ بيه واحميهولك‬s‫هاشغللك البرنامج واظبطلك ملفاته و الذاكرة الي محتاجها و االجهزة الي هتتوصل‬
1-process control
2-file management
3-device management
4-memory management
5-communication
6-protection

15) What is the main advantage of the layered approach to system design?
It provides modularity (‫)نمطية‬, abstraction (‫)تجريد‬, and separation (‫ )انفصال‬of concerns, which leads to
a more manageable, maintainable, and efficient system.

Simplicity of construction and debugging as layer are selected such that each use functions and
services of only lower-level layer.

16) What is the main advantage of the microkernel approach to system design?
Adding a new service doesn’t require modifying the kernel and also more secure.

17) What are the advantages and disadvantages of using the same system call interface for
manipulating both files and devices?
Advantages: simplicity, consistency (‫)االتساق‬, and ease of use. Disadvantages: reduced flexibility and
limited device-specific features.

‫دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة‬ Page 7
Assignment 2
1) When a process creates a new process using the fork () operation, which of the
following states is Shared between the parent process and the child process?

a) Stack b) Heap c) Shared memory segments

c) Shared memory segments like code segment and data segment.

2) Briefly explain
a) The layout of process in memory

1- Text section: Contains the code instructions of the program.


2- Data section: Stores global variables.
3- Heap: A region of memory used for dynamic memory allocation
during runtime.
4- Stack: A region of memory used for temporary data storage during
function calls and other program executions.

b) Process control block (PCB)

1- Process state: new, running, waiting, ready, terminated.


2- Process number: PID
3- Program counter: location of instruction to next execute
4- Memory limits: memory management information
5- List of open file

‫دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة‬ Page 8
c) The different states of a process.

1- New: the process is being created.


2- Running: instructions are being executed.
3- Waiting: the process is waiting for some event to occur.
4- Ready: the process is waiting to be assigned to the processor.
6- Terminated: the process has finished execution.

d) Representation of process scheduling


Process scheduler selects among available processes for next execution on the CPU
The goal of this scheduling to maximize CPU use, and quickly switch processes onto CPU
core using two queues (ready queue, wait queue).

e) Context switching steps to switch from process to process.

‫دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة‬ Page 9
f) The difference between message passing and shared memory communications
models.

(a) Shared memory. (b) Message passing.

Shared memory:
Processes access a shared region of memory,
Logical (direct form of communication),
Faster/more efficient.
Message passing:
Processes send/receive messages through queue/mailbox,
Logical (indirect form of communication),
More secure/reliable communication.

‫دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة‬ Page 10
3) What are the steps performed by an OS to create a new process?

1- Allocate memory space for the new process. ‫المساحة‬


2- Load program code and data into memory. ‫حمل البرنامج فالرام‬
3- Assign a PID to the process. ‫اديله رقم‬
4- Set up system resources, such as PCB and memory management. ‫شوفة محتاج ايه‬
5- Set initial process state, including program counter and stack pointer. ‫حالة البروسيس فالوقت الحالي ايه‬
6- Add process to scheduling queue. ‫اديها دور عشان تتنفذ‬
7- Start the process by transferring control to its program counter. ‫ابداء‬

4) What are the steps performed by an OS to terminate process?

1- Send signal to process to terminate. ‫ خالص معدتش محتاجك‬:‫اسمع‬

2- Remove process from scheduling queue. ‫وخرجتك من كل حساباتي‬

3- Free up allocated resources. )‫وهات الهدايا الي كنت مديهالك (الرامات و المساحات‬

4- Terminate any child processes. ‫كدا كل الي بيننا انتهي الغيلي البروسيس بتاعتك دي‬

5- Notify parent process of termination. ‫وهابلغ ابوك بالي حصل بيننا‬

6- Remove process control block and associated data structures. ‫مسح تااااااااام‬

‫دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة‬ Page 11
Another questions
1. What is an operating system?
a) interface between the hardware and application programs
b) collection of programs that manages hardware resources
c) system service provider to the application programs
d) all of the mentioned
2. What is the main function of the command interpreter?
a) to provide the interface between the API and application program
b) to handle the files in the operating system
c) to get and execute the next user-specified command
d) none of the mentioned
3. In Operating Systems, which of the following is/are CPU scheduling algorithms?
a) Priority
b) Round Robin
c) Shortest Job First
d) All of the mentioned
4.  To access the services of the operating system, the interface is provided by the ___________
a) Library
b) System calls
c) Assembly instructions
d) API
5. CPU scheduling is the basis of ___________
a) multiprogramming operating systems
b) larger memory sized systems

‫دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة‬ Page 12
c) multiprocessor systems
d) none of the mentioned
6. Which one of the following is not true?
a) kernel remains in the memory during the entire computer session
b) kernel is made of various modules which can’t be loaded in running operating system
c) kernel is the first part of the operating system to load into memory during booting
d) kernel is the program that constitutes the central core of the operating system
7. Which one of the following errors will be handle by the operating system?
a) lack of paper in printer
b) connection failure in the network
c) power failure
d) all of the mentioned
8. Where is the operating system placed in the memory?
a) either low or high memory (depending on the location of interrupt vector)
b) in the low memory
c) in the high memory
d) none of the mentioned
9. If a process fails, most operating system write the error information to a ______
a) new file
b) another running process
c) log file
d) none of the mentioned
10.  In operating system, each process has its own __________
a) open files
b) pending alarms, signals, and signal handlers
c) address space and global variables
d) all of the mentioned
11.  In a timeshare operating system, when the time slot assigned to a process is completed,
the process switches from the current state to?
a) Suspended state
b) Terminated state
c) Ready state
d) Blocked state

‫دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة‬ Page 13
Assignment3

1) Explain the difference between a thread and a process.

- Process is the program under action.

- Thread is the smallest segment of the instruction that can be handled independently by scheduler

2) Provide three programming examples in which multithreading provide better


performance than a single-threaded solution.

- A Web server that services each request in a separate thread.


- A parallelized application such as matrix multiplication where different parts of the matrix may be worked
on in parallel
- An interactive GUI program such as a debugger where a thread is used to monitor user input, another
thread represents the running application, and a third thread monitors performance.

3) What are two differences between user-level threads and kernel-level threads? Under
what circumstances is one type better than the other?

- User-level threads are managed by the application (user) and have less overhead, while kernel-
level threads are managed by the operating system and have more powerful features. The choice
between them depends on the specific requirements of the application.
‫اجابة اخري‬
- User-level threads are unknown by the kernel, whereas the kernel is aware of kernel threads.
- Kernel threads are generally more expensive to maintain than user threads as they must be represented
with a kernel data structure.
- User-level threads managed by user-level threads library like (POSIX, windows, Java). Kernel threads
supported by the kernel like (windows, Linux, IOS).

‫دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة‬ Page 14
4) Which of the following components of program state are shared across threads in
a multithreaded process?

a) Register values
b) Heap memory
c) Global variables
d) Stack

5) Briefly explain the advantages of the many-to-many threading model over the one-
to-one threading models.

- The many-to-many threading model is more efficient than the one-to-one model, as it maps multiple user-
level threads to fewer kernel-level threads, resulting in better performance, scalability, resource utilization,
and responsiveness.

One-to-one many-to-many

‫دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة‬ Page 15
Assignment4
1. Explain the difference between preemptive and non-preemptive scheduling.

- Preemptive scheduling interrupts a process/thread without its cooperation, while non-preemptive


scheduling requires voluntary CPU release.
- Preemptive scheduling is more flexible and responsive, while non-preemptive scheduling is simpler
but can result in poor resource utilization.

2. Consider the following set of processes, with the length of the CPU burst time is given in
milliseconds:
Process ID Arrival Priority Burst Time
Time
1 0 20 10
2 2 10 1
3 4 58 2
4 8 40 4
5 12 30 3

a. Draw Gantt charts that illustrate the execution of these processes using the following
scheduling algorithms: FCFS, SJF, HPF, and RR (quantum = 2).
b. What is the turnaround time of each process for each of the scheduling algorithms in part a?
c. What is the waiting time of each process for each of these scheduling algorithms?
d. Which of the algorithms results in the minimum average waiting time (over all
processes)?

- FCFS

P1 P2 P3 P4 P5
0 10 11 13 17 20

Average wait = (0+(10-2)+(11-4)+(13-8)+(13-12))/5=21/5


- SJF

P2 P3 P5 P4 P1
0 1 3 6 10 20

‫دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة‬ Page 16
Average wait = (0+1+3+6+10+20)/5=
- RR (quantum = 2).

P1 P2 P3 P1 P4 P1 P4 P5 P1 P5 P1
0 2 4 6 8 10 12 14 16 18 20 22 24
Average wait = p1 = (0+(6-2)+(10-8)+(16-12))= 10
P2 = (0)
P3 = (0)
P4 = (0+(12-10))= 2
P5 = (2+(18-16))= 4
Average wait =16/5

- HPF

P3 P4 P5 P1 P2
0 2 6 9 19 20

Average wait =(0+2+6+9+19+20)/5=

‫دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة‬ Page 17

You might also like