Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
www.ignousite.blogspot.com
MASTER OF COMPUTER
APPLICATIONS
(MCA)
MCA/ASSIGN/SEMESTER-IV
ASSIGNMENTS
(July - 2016 & January - 2017)
Arrival Execution
Process Priority
Time Time
P1 0 4 5
P2 3 12 4
P3 5 9 3
P4 5 2 2
P5 7 6 1
(i) Draw the Gantt charts illustrating the execution of these processes using the FCFS,
SJF, Round Robin (with quantum = 1) and Priority Based Scheduling algorithms.
(ii) Also calculate the average turnaround time, average waiting time, processor utilization
and throughput for each of the algorithms mentioned in (i).
Answer:
If the processes arrive as per the arrival time in the given table of question, the Gantt chart will be
as follows:
P1 P2 P3 P4 P5
0 4 16 25 27 33
P1 P4 P5 P3 P2
0 4 6 12 21 33
Each process is allocated a small time-slice called quantum. No process can run for
more than one quantum while others are waiting in the ready queue. If a process needs
more CPU time to complete after exhausting one quantum, it goes to the end of ready
queue to await the next allocation. To implement the RR scheduling, Queue data
structure is used to maintain the Queue of Ready processes. A new process is added at
the tail of that Queue. The CPU schedular picks the first process from the ready
Queue, Allocate processor for a specified time Quantum. After that time the CPU
schedular will select the next process is the ready Queue.
Using time quantum 1 the Gantt chart for Round Robin scheduling will be as below:
P1 P2 P3 P4 P5 P1 P2 P3 P4 P5 P1 P2 P3 P5 P1 P2 P3
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
P5 P2 P3 P5 P2 P3 P5 P2 P3 P2 P3 P2 P3 P2 P2 P2
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
Ignou Study Helper
www.ignousite.blogspot.com
Priority Based Scheduling or Event-Driven (ED) Scheduling
A priority is associated with each process and the scheduler always picks up the
highest priority process for execution from the ready queue. Equal priority processes
are scheduled FCFS. The level of priority may be determined on the basis of resource
requirements, processes characteristics and its run time behaviour.
A major problem with a priority based scheduling is indefinite blocking of a lost
priority process by a high priority process. In general, completion of a process within
finite time cannot be guaranteed with this scheduling algorithm. A solution to the
problem of indefinite blockage of low priority process is provided by aging priority.
Aging priority is a technique of gradually increasing the priority of processes (of low
priority) that wait in the system for a long time. Eventually, the older processes attain
high priority and are ensured of completion in a finite time.
Gantt Chart:
P5 P4 P3 P2 P1
0 6 8 17 29 33
Answer:
(I) LRU replacement algorithm:
If the optimal algorithm is not feasible, perhaps an approximation of the optima] algorithm is
possible. The key distinction between the FIFO and OPT algorithms (other than looking backward
versus forward in time) is that the FIFO algorithm uses the time when a page was brought into
memory, whereas the OPT algorithm uses the time when a page is to be used. If we use the
recent past as an approximation of the near future, then we can replace the page that has not
been used for the longest period of time (Figure 9.15). This
approach is the least-recently-used (LRU) algorithm.
Page Reference 1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
1 1 1 1 1 1 5 5 5 5 5 3 3 3 3 3 3 3 3 3
Page Frames 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
(4) 3 3 3 3 3 6 6 6 6 6 7 7 7 7 1 1 1 1
4 4 4 4 4 4 1 1 1 1 6 6 6 6 6 6 6
Page Faults (Y/N) Y Y Y Y Y Y Y Y Y Y Y
Page Faults = 11
Ignou Study Helper
Advantages www.ignousite.blogspot.com
Advantages of LRU Page Replacement Algorithm:
1. It is amenable to full statistical analysis.
2. Never suffers from Belady’s anomaly.
Disadvantages
To identify the page to replace, you need to find the minimum time stamp value in all the
registers.
Page Reference 1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
1 1 1 1 1 1 5 5 5 5 5 3 3 3 3 3 1 1 1 1
Page Frames 2 2 2 2 2 2 6 6 6 6 6 7 7 7 7 7 7 3 3
(4) 3 3 3 3 3 3 2 2 2 2 2 6 6 6 6 6 6 6
4 4 4 4 4 4 1 1 1 1 1 1 2 2 2 2 2
Page Faults (Y/N) Y Y Y Y Y Y Y Y Y Y Y Y Y Y
Page Faults = 14
Advantages of FIFO
1. Obvious improvement over FIFO
2. Allows commonly used pages to stay in queue
Disadvantages of FIFO
.Still suffers from Belady's anomaly
One result of the discovery of Belady's anomaly was the search for an optimal page-
replacement algorithm. An optimal page-replacement algorithm has the lowest page-fault rate of all
algorithms and will never suffer from Belady's anomaly. Such an algorithm does exist and has
been called OPT or MIK.
Page Reference 1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
1 1 1 1 1 1 1 1 1 1 1 1 7 7 7 7 1 1 1 1
Page Frames 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
(4) 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
4 4 4 5 6 6 6 6 6 6 6 6 6 6 6 6 6
Page Faults (Y/N) Y Y Y Y Y Y Y Y
Page Faults = 8
Ignou Study Helper
www.ignousite.blogspot.com
Advantage
Advantage of the optimal page replacement algorithm is that it has the lowest rate of
occurrence of page faults. Hypothetically, it improves the system performance by reducing
overhead for number of page faults and swapping pages in and out, when a page fault occurs.
Disadvantage
Disadvantage of the optimal page replacement policy is that it is very difficult to implement.
The situation is very similar to that of implementing the SJF algorithm in process management. It
becomes very difficult for an operating system to calculate after what interval a page is to be
referred to.
Answer: Five philosophers sit around a circular table. Each philosopher spends his life alternatively
thinking and eating. In the centre of the table is a large bowl of rice. A philosopher needs two chopsticks to
eat. Only 5 chop sticks are available and a chopstick is placed between each pair of philosophers. They
agree that each will only use the chopstick to his immediate right and left. From time to time, a philosopher
gets hungry and tries to grab the two chopsticks that are immediate left and right to him. When a hungry
philosopher has both his chopsticks at the same time, he eats without releasing his chopsticks. When he
finishes eating, he puts down both his chopsticks and starts thinking again.
Here’s a solution for the problem which does not require a process to write another process’s state, and
gets equivalent parallelism.
Condition Variables: If a process cannot enter the monitor it must block itself. This operation is provided by
the condition variables. Like locks and semaphores, the condition has got a wait and a signal function. But it
also has the broadcast signal. Implementation of condition variables is part of a synch.h; it is your job to
implement it.
Q4. Study and implement the Lamport’s Bakery Algorithm for Interprocess synchronization
using C/C++ programming language.
Answer:
Lamport's bakery algorithm: Lamport's bakery algorithm is a computer algorithm devised by
computer scientist Leslie Lamport, which is intended to improve the safety in the usage of shared resources
among multiple threads by means of mutual exclusion.
In computer science, it is common for multiple threads to simultaneously access the same
resources. Data corruption can occur if two or more threads try to write into the same memory location, or if
one thread reads a memory location before another has finished writing into it. Lamport's bakery algorithm
is one of many mutual exclusion algorithms designed to prevent concurrent threads entering critical
sections of code concurrently to eliminate the risk of data corruption.
Ignou Study Helper
www.ignousite.blogspot.com
Analogy: Lamport envisioned a bakery with a numbering machine at its entrance so each customer is
given a unique number. Numbers increase by one as customers enter the store. A global counter displays
the number of the customer that is currently being served. All other customers must wait in a queue until the
baker finishes serving the current customer and the next number is displayed. When the customer is done
shopping and has disposed of his or her number, the clerk increments the number, allowing the next
customer to be served. That customer must draw another number from the numbering machine in order to
shop again.
According to the analogy, the "customers" are threads, identified by the letter i, obtained from a
global variable.
Due to the limitations of computer architecture, some parts of Lamport's analogy need slight
modification. It is possible that more than one thread will get the same number n when they request it; this
cannot be avoided. Therefore, it is assumed that the thread identifier i is also a priority. A lower value of i
means a higher priority and threads with higher priority will enter the critical section first.
Words choosing [i] and number [i] are in the memory of process i, and are initially zero.
The range of values of number [i] is unbounded.
A process may fail at any time. We assume that when it fails, it immediately goes to its noncritical
section and halts. There may then be a period when reading from its memory gives arbitrary values.
Eventually, any read from its memory must give a value of zero.
Study and implement the Lamport’s Bakery Algorithm for Interprocess synchronization
using C/C++ programming language:
#include(pthread.h)
#include(stdio.h>
#include(unistd.h>
#include (assert.h>
volatile int NUM_THREADS = 10;
volatile int Number[10] = {0};
volatile int count_cs[10] = {0};
volatile int Entering[10] = {0};
int max()
{
int i = 0;
int j = 0;
int maxvalue = 0;
for(i = 0; i < 10; i++)
{
if ((Number[i]) > maxvalue)
{
maxvalue = Number[i];
}
}
return maxvalue;
}
lock(int i)
{
int j;
Entering[i] = 1;
Number[i] = 1 + max();
Entering[i] = 0;
Ignou Study Helper
www.ignousite.blogspot.com
for (j = 1; j <= NUM_THREADS; j++)
{
while (Entering[j]) { } /* Do nothing */
while ((Number[j] != 0) &&
((Number[j] < Number[i]) ||
((Number[j] == Number[i]) && (j < i)))) { }
}
}
unlock(int i) {
Number[i] = 0;
}
void Thread(int i) {
while (1) {
lock(i);
count_cs[i+1] = count_cs[i+1] + 1 ;
//printf("critical section of %d\n", i+1);
unlock(i);
}
}
int main()
{
int duration = 10000;
pthread_t threads[NUM_THREADS];
int rc;
long t;
for(t = 0; t < NUM_THREADS; t++){
printf("In main: creating thread %ld\n", t+1);
rc = pthread_create(&threads[t], NULL, Thread, (int)t);
if (rc){
printf("ERROR; return code from pthread_create() is %d\n", rc);
exit(-1);
}
}
usleep(duration*1000);
for(t=0; t < NUM_THREADS; t++)
{
printf("count of thread no %d is %d\n",t+1,count_cs[t+1]);
}
return 0;
}
Q4. Discuss in detail the features, Process management, Memory management, I/O and File
management and Security and Protection in Windows 10 Operating System.
Answer:
Windows 10 features:
1. The Start menu: Windows 10 atones for one of Windows 8’s greatest sins by returning the Start
menu to its rightful spot in the lower left-hand corner of the desktop. But rather than focusing on
desktop apps alone, the Windows 10 Start menu mixes in a dash of the Metro Start screen’s
functionality, sprinkling Live Tiles of Windows 8-style apps next to shortcuts to more traditional PC
software.
You can turn off that Live Tile functionality if you’d like, and even unpin all the Metro apps
from the Start menu, returning it to purely desktop-focused glory. Or you can choose to have the
Start menu expand to the full screen, and resize Metro apps to recreate a more Windows 8-like
experience.
Ignou Study Helper
www.ignousite.blogspot.com
2. Windowed Windows Store apps: As you might have caught onto by now, those reviled
Windows Store apps from Windows 8 haven’t been eradicated—but they have been remolded to fit
desktop sensibilities. In Windows 10, launching a Windows app on your PC opens it in a desktop
window, rather than dumping you into a full-screen app. The windowed apps have a mouse-friendly
toolbar of options across the top, and even alter their interface to best fit the size of the window.
3. Cortana: Cortana, Microsoft’s clever digital assistant on Windows Phone 8.1, makes the jump to
PCs with Windows 10, where she assumes control of the operating system’s search functions.
Cortana will want to access your personal info, then use that info along with her Bing-powered cloud
smarts to intelligently surface information you’re looking for and perform other helpful tasks.
4. The Edge Browser: The new browser in Windows 10, Microsoft Edge includes some very
powerful features. That’s not all it has to offer. It offers, safe, secure and fast browsing experience.
In this post, we will see some of the powerful features of Edge browser.
5. Virtual Desktop: We know there’s a vocal set of people who just love virtual desktops. Having
desktops beyond the limitations of a physical display is a powerful way to organize and quickly
access groups of windows. Virtual desktops aren’t new. In fact, Xerox PARC created one of the
earliest virtual desktop experiences called Rooms back in the 1980s and subsequently made a
version available for Windows 3.x. Microsoft offered the Virtual Desktop Manager as part of the
Windows XP PowerToys and a little while later released the Sysinternals Desktops add-on which
enabled similar functionality. Many other OSes and third-party utilities have also embraced the
power of virtual desktops. Given the growing popularity of this organizational tool, we decided to
build a native virtual desktop experience directly into Windows 10.
The File Explorer ribbon, which resembles the ribbon featured in Microsoft Office. The ribbon contains
buttons for common tasks to perform with your files and folders.
The Navigation Pane gives you access to your libraries of documents and pictures, as well as your storage
devices. It also features frequently used folders and network devices.
The Frequent folders section on the right features the folders you’ve worked with recently to allow for quick
access to them.
Ignou Study Helper
www.ignousite.blogspot.com
The Recent files section in the lower part of the window features files and documents that you’ve opened
recently.
Windows 10 – Security:
Windows 10 features a series of tools to help you protect your computer from threats like viruses
and other malware. The three main security tools are −
>User Account Control
>Windows Defender
>Windows Firewall
User Account Control: The Windows User Account Control is a tool that warns you when someone or
something attempts to change your computer system settings. When this happens, the screen will alert you until
an Administrator can confirm the change. This helps protect your computer against accidental changes or
malicious software altering your settings.
Initially, this User Account Control is set at a moderate to high level, which means it will notify you only
when an application tries to make changes to your computer. However, you can change this setting to your
desired level
Windows Defender: Windows Defender is an antivirus and malware protection included in your operating
system. It allows you to scan your computer for malicious software, while also checking each file or program
you open.
To configure Windows Defender, follow these steps −
Here you can customize settings like turning off real-time protection or activating cloudbased
protection, which allows Defender to send Microsoft information about security threats it finds.
Windows Firewall: Windows Firewall prevents unauthorized access from outside to get into your computer. By
default, it is turned on to protect your computer and your network.
If you want to customize your Firewall, follow these steps −
Step 1 − Open the Control Panel by searching for it in the Search bar.