OS Assignments
OS Assignments
Operating System
Assignments
دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة Page 1
Assignment1
دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة Page 2
• Computer Startup
دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة Page 3
2) What are the three main purposes of an operating system?
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
Interrupt is triggered by hardware device to allow the processor to execute the corresponding
interrupt handler routine.
• 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.
(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
دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة Page 5
Lower CPU utilization ( )استخدامand faster data transfer.
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.
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.
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?
2) Briefly explain
a) The layout of process in memory
دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة Page 8
c) The different states of a process.
دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة Page 9
f) The difference between message passing and shared memory communications
models.
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?
3- Free up allocated resources. )وهات الهدايا الي كنت مديهالك (الرامات و المساحات
4- Terminate any child processes. كدا كل الي بيننا انتهي الغيلي البروسيس بتاعتك دي
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
- Thread is the smallest segment of the instruction that can be handled independently by scheduler
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.
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
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
دعوة حلو ة من قلبك بنية صافية المالئكة تقولك ولك بمثلة Page 17