VELAMMAL INSTITUTE OF TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
CS8493- Operating System
CONTENT BEYOND SYLLABUS
1. MAC OS & Mircro Kernel Features:
MacOS ( previously Mac OS X andlater OS X) is a series of proprietary graphical operating
systems developed and marketed by Apple Inc. since 2001. It is the primary operating system for
Apple's Mac computers. Within the market of desktop, laptop and home computers, and by web
usage, it is the second most widely used desktop OS, after Microsoft Windows.
MacOS is based on the Unix operating system and on technologies developed between 1985
and 1997 at NeXT, a company that Apple co-founder Steve Jobs created after leaving Apple in 1985.
The "X" in Mac OS X and OS X is the Roman numeral for the number 10 and is pronounced as such.
The X was a prominent part of the operating system's brand identity and marketing in its early years,
but gradually receded in prominence since the release of Snow Leopard in 2009. UNIX
03 certification was achieved for the Intel version of Mac OS X 10.5 Leopard and all releases
from Mac OS X 10.6 Snow Leopard up to the current version also have UNIX 03
certification. macOS shares its Unix-based core, named Darwin, and many of
its frameworks with iOS, iPadOS, tvOS, and watchOS.
In Mac OS 9, applications cooperate to share processor time. Similarly, all applications share
the memory of the computer among them. Mac OS 9 is a cooperative multitasking environment. The
responsiveness of all processes is compromised if even a single application doesn’t cooperate. On the
other hand, real-time applications such as multimedia need to be assured of predictable, time-critical,
behavior.
In contrast, OS X is a preemptive multitasking environment. In OS X, the kernel provides
enforcement of cooperation, scheduling processes to share time (preemption). This supports real-time
behavior in applications that require it.
Mach manages processor resources such as CPU usage and memory, handles scheduling,
provides memory protection, and provides a messaging-centered infrastructure to the rest of the
operating-system layers. The Mach component provides
untyped interprocess communication (IPC)
remote procedure calls (RPC)
scheduler support for symmetric multiprocessing (SMP)
support for real-time services
virtual memory support
support for pagers
modular architecture
Microkernel of Mac OS:
Microkernel manages all system resources. In this type of kernel, services are implemented in
different address space. The user services are stored in user address space, and kernel services are
1
stored under kernel address space. So, it helps to reduce the size of both the kernel and operating
system.
Architecture of MAC OS
2. Selfish Round Robin Scheduling Algorithm
In the traditional Round Robin scheduling algorithm all processes were treated equally for
processing. The objective of the Selfish Round Robin is to give better service to processes that have
been executing for a while than to newcomers. Its a more logical and superior implementation
compared to the normal Round Robin algorithm.
Implementation :-
Processes in the ready list are partitioned into two lists: NEW and ACCEPTED.
The New processes wait while Accepted processes are serviced by the Round Robin.
Priority of a new process increases at rate ‘a’ while the priority of an accepted process
increases at rate ‘b’.
When the priority of a new process reaches the priority of an accepted process, that new
process becomes accepted.
If all accepted processes finish, the highest priority new process is accepted.
STEP 1 : Assume that initially there are no ready processes, when the first one, A, arrives. It has
priority 0 to begin with. Since there are no other accepted processes, A is accepted immediately.
STEP 2 : After a while another process, B, arrives. As long as b / a < 1, B’s priority will
eventually catch up to A’s, so it is accepted; now both A and B have the same priority.
STEP 3 : All accepted processes share a common priority (which rises at rate b ); that makes this
policy easy to implement i.e any new process’s priority is bound to get accepted at some point.
2
So no process has to experience starvation.
STEP 4 : Even if b / a > 1, A will eventually finish, and then B can be accepted.
Adjusting the parameters a and b :
-> If b / a >= 1, a new process is not accepted
until all the accepted processes have finished, so SRR becomes FCFS.
-> If b / a = 0, all processes are accepted immediately, so SRR becomes RR.
-> If 0 < b / a < 1, accepted processes are selfish, but not completely.
Example on Selfish Round Robin –
Explanation –
Process A gets accepted as soon as it comes at time t = 0. So its priority is increased only by ‘b’ i.e ‘1’
after each second. B enters at time t = 1 and goes to the waiting queue. So its priority gets increased
by ‘a’ i.e. ‘2’ at time t = 2. At this point priority of A = priority of B = 2.
So now both process A & B are in the accepted queue and are executed in a round robin fashion. At
time t = 3 process C enters the waiting queue. At time t = 6 the priority of process C catches up to the
priority of process B and then they start executing in a Round Robin manner. When B finishes
execution at time t = 10, D is automatically promoted to the accepted queue.
Similarly when D finishes execution at time t = 15, E is automatically promoted to the accepted
queue.
3. Deadlock in DBMS
In a database, a deadlock is an unwanted situation in which two or more transactions are waiting
indefinitely for one another to give up locks. Deadlock is said to be one of the most feared
complications in DBMS as it brings the whole system to a Halt.
3
Example – let us understand the concept of Deadlock with an example :
Suppose, Transaction T1 holds a lock on some rows in the Students table and needs to update some
rows in the Grades table. Simultaneously, Transaction T2 holds locks on those very rows (Which T1
needs to update) in the Grades table but needs to update the rows in the Student table held by
Transaction T1.
Now, the main problem arises. Transaction T1 will wait for transaction T2 to give up lock, and
similarly transaction T2 will wait for transaction T1 to give up lock. As a consequence, All activity
comes to a halt and remains at a standstill forever unless the DBMS detects the deadlock and aborts
one of the transactions.
DeadlockAvoidance –
When a database is stuck in a deadlock, It is always better to avoid the deadlock rather than restarting
or aborting the database. Deadlock avoidance method is suitable for smaller database whereas
deadlock prevention method is suitable for larger database.
One method of avoiding deadlock is using application consistent logic. In the above given example,
Transactions that access Students and Grades should always access the tables in the same order. In
this way, in the scenario described above, Transaction T1 simply waits for transaction T2 to release
the lock on Grades before it begins. When transaction T2 releases the lock, Transaction T1 can
proceedfreely.
Another method for avoiding deadlock is to apply both row level locking mechanism and READ
COMMITTED isolation level. However, It does not guarantee to remove deadlocks completely.
DeadlockDetection
When a transaction waits indefinately to obtain a lock, The database managememt system should
detect whether the transaction is involved in a deadlock or not.
Wait-for-graph is one of the methods for detecting the deadlock situation. This method is suitable for
smaller database. In this method a graph is drawn based on the transaction and their lock on the
resource. If the graph created has a closed loop or a cycle, then there is a deadlock.
For the above mentioned scenario the Wait-For graph is drawn below
4
Deadlock prevention
For large database, deadlock prevention method is suitable. A deadlock can be prevented if the
resources are allocated in such a way that deadlock never occur. The DBMS analyzes the operations
whether they can create deadlock situation or not, If they do, that transaction is never allowed to be
executed.
4. Allocation of frames in operating system
An important aspect of operating systems, virtual memory is implemented using demand paging.
Demand paging necessitates the development of a page-replacement algorithm and a frame allocation
algorithm. Frame allocation algorithms are used if you have multiple processes; it helps decide how
many frames to allocate to each process.
There are various constraints to the strategies for the allocation of frames:
You cannot allocate more than the total number of available frames.
At least a minimum number of frames should be allocated to each process. This constraint is
supported by two reasons. The first reason is, as less number of frames are allocated, there is
an increase in the page fault ratio, decreasing the performance of the execution of the process.
Secondly, there should be enough frames to hold all the different pages that any single
instruction can reference.
Frame allocation algorithms –
The two algorithms commonly used to allocate frames to a process are:
Equal allocation: In a system with x frames and y processes, each process gets equal number of
frames, i.e. x/y. For instance, if the system has 48 frames and 9 processes, each process will get 5
frames. The three frames which are not allocated to any process can be used as a free-frame buffer
pool.
5
Disadvantage: In systems with processes of varying sizes, it does not make much sense to give each
process equal frames. Allocation of a large number of frames to a small process will eventually lead
to the wastage of a large number of allocated unused frames.
Proportional allocation: Frames are allocated to each process according to the process size.
For a process pi of size si, the number of allocated frames is ai = (si/S)*m, where S is the sum of the
sizes of all the processes and m is the number of frames in the system. For instance, in a system with
62 frames, if there is a process of 10KB and another process of 127KB, then the first process will be
allocated (10/137)*62 = 4 frames and the other process will get (127/137)*62 = 57 frames.
Advantage: All the processes share the available frames according to their needs, rather than equally.
Global vs Local Allocation –
The number of frames allocated to a process can also dynamically change depending on whether you
have used global replacement or local replacement for replacing pages in case of a page fault.
Local replacement: When a process needs a page which is not in the memory, it can bring in the new
page and allocate it a frame from its own set of allocated frames only.
Advantage: The pages in memory for a particular process and the page fault ratio is affected by the
paging behavior of only that process.
Disadvantage: A low priority process may hinder a high priority process by not making its frames
available to the high priority process.
Global replacement: When a process needs a page which is not in the memory, it can bring in the
new page and allocate it a frame from the set of all frames, even if that frame is currently allocated to
some other process; that is, one process can take a frame from another.
Advantage: Does not hinder the performance of processes and hence results in greater system
throughput.
Disadvantage: The page fault ratio of a process can not be solely controlled by the process itself. The
pages in memory for a process depends on the paging behavior of other processes as well.