27
Course: Bachelor of Technology Branch: Computer Science & Engineering Semester: 6 th GURU JAMBHESHWAR UNIVERSITY OF SCIENCE & TECHNOLOGY, HISAR Submitted To: - Submitted By:- Mr. Ajit Noonia Mukesh Kumar Asstt. Professor in CSE Deptt. 1110751908 Department of Computer Science & Engineering Prannath Parnami Institute of Management & Technology, Hisar Prannath Parnami Universe, Website: ppu.edu.in

O.s. lab all_experimets

Embed Size (px)

DESCRIPTION

Operating Sytem Lab Practicals

Citation preview

Page 1: O.s. lab all_experimets

Course: Bachelor of Technology

Branch: Computer Science & Engineering

Semester: 6th

GURU JAMBHESHWAR UNIVERSITY OF

SCIENCE & TECHNOLOGY, HISAR

Submitted To: - Submitted By:-

Mr. Ajit Noonia Mukesh Kumar

Asstt. Professor in CSE Deptt. 1110751908

Department of Computer Science & Engineering

Prannath Parnami Institute of Management & Technology, Hisar

Prannath Parnami Universe, Website: ppu.edu.in

Page 2: O.s. lab all_experimets

INDEX

Sr. No.

Name of Experiment Date Remarks

1 Study of WINDOWS 2000 Operating System.

2 WAP simulate FCFS C.P.U. Scheduling

algorithm.

3 WAP to simulate SJF C.P.U. Scheduling

algorithm.

4 WAP simulate Priority C.P.U. Scheduling

algorithm

5 WAP simulate Round Robin C.P.U.

Scheduling algorithm.

6 WAP in C Banker’s algorithm for Deadlock

Avoidance.

7 WAP in C to implement FIFO page

replacement algorithm.

8 WAP in C to implement LRU page

replacement algorithm.

Page 3: O.s. lab all_experimets

EXPERIMENT NO.=1

Aim:-- Study of WINDOWS 2000 Operating System.

Introduction to Window 2000:-

Windows 2000 is an operating system for use on both client and server computers. It was

produced by Microsoft and released to manufacturing on December 15, 1999 and launched to

retail on February 17, 2000. It is the successor to Windows NT 4.0, and is the last version of

Microsoft Windows to display the "Windows NT" designation. It is succeeded by Windows

XP (released in October 2001) and Windows Server 2003 (released in April 2003). During

development, Windows 2000 was known as Windows NT 5.0.

Four editions of Windows 2000 were released: Professional, Server, Advanced Server,

and Datacenter Server; the latter was both released to manufacturing and launched months

after the other editions. While each edition of Windows 2000 was targeted at a different

market, they shared a core set of features, including many system utilities such as

the Microsoft Management Console and standard system administration applications.

Support for people with disabilities was improved over Windows NT 4.0 with a number of

new assistive technologies and Microsoft increased support for different languages

and locale information.

All versions of the operating system support NTFS 3.0, Encrypting File System, as well as

basic and dynamic disk storage. The Windows 2000 Server family has additional features,

including the ability to provide Active Directory services (a hierarchical framework of

resources), Distributed File System (a file system that supports sharing of files) and fault-

redundant storage volumes. Windows 2000 can be installed through either a manual or

unattended installation. Unattended installations rely on the use of answer files to fill in

installation information, and can be performed through a bootable CD using

Microsoft Systems Management Server, by the System Preparation Tool.

Microsoft marketed Windows 2000 as the most secure Windows version ever at the time;

however, it became the target of a number of high-profile virus attacks such as Code

Red and Nimda. For ten years after its release, it continued to receive patches for security

vulnerabilities nearly every month until reaching the end of its lifecycle on July 13, 2010.

System Components:--

The architecture of Windows is a layered system of modules, as shown in Figure. The main

layers are the HAL, the kernel, and the executive, all of which run in protected mode, and a

large collection of subsystems that run in user mode. The user-mode subsystems are in two

categories. The environmental subsystems emulate different operating systems the protection

subsystems provide security functions. One of the chief advantages of this type.

Page 4: O.s. lab all_experimets

Fig. Windows block diagram

16-Bit Windows Environment:--

The Win16 execution environment is provided by a VDM that incorporates additional

software, called Windows on Windows, that provides the Windows 3.1 kernel routines and

stub routines for window-manager and graphical device- interface (GDI) functions. The stub

routines call the appropriate Win32 subroutines—converting, or thunking, 16-bit addresses

into 32-bit ones. Applications that rely on the internal structure of the 16-bit window manager

or GDI may not work, because Windows on Windows does not really implement the 16-bit

API. Windows on Windows can multitask with other processes on Windows, but it resembles

Windows 3.1 in many ways. Only oneWin16 application can run at a time, all applications are

single threaded and reside in the same address space, and all share the same input queue.

These features imply that an application that stops receiving input will block all the other

Win16 applications, just a in Windows 3.x, and one Win16 application can crash other Win16

applications by corrupting the address space. Multiple Win16 environments can coexist,

however, by using the command start /separate win16application from the command line.

Page 5: O.s. lab all_experimets

Win32 Environment:--

As mentioned earlier, the main subsystem in Windows is theWin32 subsystem. It runs Win32

applications and manages all keyboard, mouse, and screen I/O. Since it is the controlling

environment, it is designed to be extremely robust. Several features of Win32 contribute to

this robustness. Unlike processes in the Win16 environment, each Win32 process has its own

input queue. The window manager dispatches all input on the system to the appropriate

process’s input queue, so a failed process will not block input to other processes. The

Windows kernel also provides preemptive multitasking, which enables the user to terminate

applications that have failed or are no longer needed. In addition, Win32 validates all objects

before using them, to prevent crashes that could otherwise occur if an application tried to use

an invalid or wrong handle. The Win32 subsystem verifies the type of the object to which a

handle points before using that object. The reference counts kept by the object manager

prevent objects from being deleted while they are still being used and prevent their use after

they have been deleted.

Domains:-- Many networked environments have natural groups of users, such as students in a computer

laboratory at school or employees in one department in a business. Frequently, we want all the

members of the group to be able to access shared resources on their various computers in the

group. To manage the global access rights within such groups, Windows uses the concept of a

domain. Previously, these domains had no relationship whatsoever to the domain name system

(DNS) that maps Internet host names to IP addresses; now, however, they are closely related.

Specifically, a Windows domain is a group of Windows workstations and servers that share a

common security policy and user database. Since Windows now uses the Kerberos protocol for

trust and authentication, a Windows domain is the same thing as a Kerberos realm. Previous

versions of NT used the idea of primary and backup domain controllers; now all servers in a

domain are domain controllers. In addition, previous versions required the setup of one way

trusts between domains. Windows uses a hierarchical approach based on DNS and allows

transitive trusts that can flow up and down the hierarchy. This approach reduces the number of

trusts required for n domains from n ∗ (n−1) to O(n). The workstations in the domain trust the

domain controller to give correct information about the access rights of each user (via the user’s

access token). All users retain the ability to restrict access to their own work stations, no matter

what any domain controller may say. Because a business may have many departments and a

school may have many classes, it is often necessary to manage multiple domains within a

single organization. A domain tree is a contiguous DNS naming hierarchy for managing

multiple domains. For example, bell-labs.com might be the root of the tree, with research.bell-

labs.com and pez.bell-labs.com as children—domains research and pez. A forest is a set of

noncontiguous names. An example would be the trees bell-labs.com and/or lucent.com. A forest

may be made up of only one domain tree, however. Trust relationships can be set up between

domains in three ways: one-way, transitive, and cross-link. Versions of NT through Version 4.0

allowed only

one-way trusts to be set up. A one- way trust is exactly what its name implies: Domain A is told

it can trust domain B. However, B will not trust A unless another relationship is configured.

Under a transitive trust, if A trusts B and B trusts C, then A, B, and C all trust one another,

since transitive trusts are two-way by default. Transitive trusts are enabled by default for new

domains in a tree and can be configured only among domains within a forest. The third type, a

Page 6: O.s. lab all_experimets

cross-link trust, is useful to cut down on authentication traffic. Suppose that domains A and B

are leaf nodes and that users in A often use resources in B. If a standard transitive trust is used,

authentication requests must traverse up to the common ancestor of the two leaf nodes; but if A

and B have a cross linking trust established, the authentications can be sent directly to the other

node.

System Administrator of Window 2000:--

Features of Window 2000:--

Page 7: O.s. lab all_experimets

Features Functions Benefits

Greater system stability

Improved hardware

support Supports AGP, DVD,

USB, IEEE 1394.

Improved DirectX®

and DirectSound®

support.

Computers are more compatible and more

stable than with previous Microsoft®

operating systems. This is due in part to

fewer driver conflicts and increased ease of

setup.

Improved program

support Microsoft claims 600

new programs tested as

being compatible.

Improved productivity, through ability

to use a wider variety of programs.

Less downtime spent troubleshooting

technical issues associated with

program incompatibility.

New Microsoft®

Windows® Installer Provides a standard

format for program

setup, including

installation and repair.

Tracks key files and

automatically replaces

or repairs damaged

files.

Helps to provide more reliable

programs.

Contributes to efficiency in systems

management.

Helps prevent DLL conflicts.

Auto restart of failed

services Automatically caches

data in progress.

Better retention of data.

Less downtime.

Improved stability.

Page 8: O.s. lab all_experimets

Increased manageability

Active

directory Dynamic linking of

system, user, and

enterprise information.

For the system administrator, simplified

system and asset administration over the

network.

For the user, easier access to shared

network devices.

IntelliMirror®

Duplicates user profiles

and data, including

security permissions,

directory accesses, and

local computer data and

programs onto the

server.

Faster installation of new computers.

Protection from data loss.

Group setup of security and access levels.

Easier administration of portable

computers.

Better support of roaming users.

Easier replacement of failed computers —

reduces downtime.

Easier administration of corporate

standards.

Distribution of software upgrades without a

service call; provides unattended

installation procedures.

ACPI Manages system,

device, processor

power, battery, and

system events.

Provides instant on,

instant off power.

Offers power-saving

features.

Provides Wake up on

LAN feature.

Power savings equate to lower electricity

bills.

Remote systems management through

Wake up on LAN.

Improved mobile power management.

Web Based

Enterprise

Management

(WBEM)

Support for Internet

protocol standards.

Allows IT managers to manage their

environments from anywhere with Web

access.

Allows easier management of remote

computers.

Page 9: O.s. lab all_experimets

Increased performance Optimized for

Pentium® II

processors

and above.

Takes advantage of the latest

advances in Intel® processing

technologies.

According to Microsoft, greater

computer performance over

Windows 95.

Higher program performance.

Enhanced

search for

files or

folders

Automatically lists recent network

locations visited and allows user to

search multiple network resources

and recently visited Internet

resources simultaneously.

Makes searching for

information more automated.

Greater system security

Encrypted

File System

with NTFS

5.0

Ability to encrypt data to the local

hard disk.

Applies additional security

permissions to the hard disk and

uses the Encrypting File System

(EFS) to protect sensitive

information.

Protects hard disk data even if

the hard disk is physically

removed from the computer.

Public key

support

Allows digital signatures for

programs, drivers, and computers.

Verifies authenticity of

components.

Allows users to set up secure

network communications over a

public network.

Authenticates e-mail source.

Internet

Protocol

Security

(IPSec)

Encrypts of data above the

network layer.

Helps protect against

unauthorized users obtaining

information over the Internet

through the World Wide Web

and maintains confidentiality.

Greater Web-browsing experience Internet

Explorer 5.0 According to Microsoft, offers a

20 percent increase in the speed of

Web page loading.

Improves the organization of

Favorites.

Increased productivity.

Greater flexibility in organizing

URLs.

Page 10: O.s. lab all_experimets

Experiment No.=2

Aim:-- WAP simulate FCFS C.P.U. Scheduling algorithm.

#include<stdio.h>

#include<conio.h>

void main()

{

char pn[10] [10];

int arr[10],bur[10],star[10],finish[10],tat[10],wt[10],i,n;

int totwt=0, tottat=0;

clrscr();

printf("enter the no of process ");

scanf("%d",&n);

for(i=0;i<n;i++)

{

printf("enter the process name, arrival time & burst time");

scanf("%s%d%d",&pn[i], &arr[i], &bur[i]);

}

for(i=0;i<n;i++)

{

if(i==0)

{

star[i]=arr[i];

wt[i]=star[i]-arr[i];

finish[i]=star[i]+bur[i];

tat[i]=finish[i]-arr[i];

}

else

{

star[i]=finish[i-1];

wt[i]=star[i]-arr[i];

finish[i]=star[i]+bur[i];

tat[i]=finish[i]-arr[i];

}}

printf("\n pname arrtime burtime start tat finish");

for(i=0;i<n;i++)

{

printf("\n %s \ %6d \ % 6d\%6d\%6d\%6d" ,pn[i],arr[i],bur[i],star[i],tat[i],finish[i]);

totwt +=wt[i];

tottat+=tat[i];

}

printf("\n average waiting time: %f",(float) totwt/n);

printf("\n average turn around time: %f",(float) totwt/n);

getch();

}

Output:--

Page 11: O.s. lab all_experimets

Experiment No.=3

Page 12: O.s. lab all_experimets

Aim:-- WAP to simulate SJF C.P.U. Scheduling algorithm.

#include<stdio.h>

#include<conio.h>

void main()

{

int i,j,n,brust_time[10],start_time[10],end_time[10],wait_time[10],temp,tot;

float avg;

clrscr();

printf("Enter the No. of jobs:");

scanf("%d",&n);

for(i=1;i<=n;i++)

{

printf("Enter %d process burst time:",i);

scanf("%d",&brust_time[i]);

}

for(i=1;i<=n;i++)

{

for(j=i+1;j<=n;j++)

{

if(brust_time[i]>brust_time[j])

{

temp=brust_time[i];

brust_time[i]=brust_time[j];

brust_time[j]=temp;

}

}

if(i==1)

{

start_time[1]=0;

end_time[1]=brust_time[1];

wait_time[1]=0;

}

else

{

start_time[i]=end_time[i-1];

end_time[i]=start_time[i]+brust_time[i];

wait_time[i]=start_time[i];

}

}

printf("\n\n BURST TIME \t STARTING TIME \t END TIME \t WAIT TIME\n");

printf("\n ********************************************************\n");

for(i=1;i<=n;i++)

Page 13: O.s. lab all_experimets

{

printf("\n %5d %15d %15d %15d",brust_time[i],start_time[i],end_time[i],wait_time[i]);

}

printf("\n ********************************************************");

for(i=1,tot=0;i<=n;i++)

tot+=wait_time[i];

avg=(float)tot/n;

printf("\n AVERAGE WAITING TIME=%f",avg);

for(i=1,tot=0;i<=n;i++)

tot+=end_time[i];

avg=(float)tot/n;

printf("\n\n AVERAGE TURNAROUND TIME=%f",avg);

for(i=1,tot=0;i<=n;i++)

tot+=start_time[i];

avg=(float)tot/n;

printf("\n\n AVERAGE RESPONSE TIME=%f\n\n",avg);

getch();

}

Output:--

Page 14: O.s. lab all_experimets

Experiment No.=4

Aim:-- WAP simulate Priority C.P.U. Scheduling algorithm. #include<stdio.h>

#include<conio.h>

int main()

Page 15: O.s. lab all_experimets

{

int i,j,n,time,sum_wait=0,sum_turnaround=0;

int smallest,at[10],bt[10],priority[10],remain;

printf("Enter no of Processes : ");

scanf("%d",&n);

clrscr();

remain=n;

for(i=0;i<n;i++)

{

printf("Enter arrival time, burst time and priority for process p%d :",i+1);

scanf("%d",&at[i]);

scanf("%d",&bt[i]);

scanf("%d",&priority[i]);

}

priority[9]=11;

printf("\n\nProcess\t|Turnaround time|waiting time\n");

for(time=0;remain!=0;)

{

smallest=9;

for(i=0;i<n;i++)

{

if(at[i]<=time && priority[i]<priority[smallest] && bt[i]>0)

{

smallest=i;

}}

time+=bt[smallest];

remain--;

printf("P[%d]\t|\t%d\t|\t%d\n",smallest+1,time-at[smallest],time-at[smallest]-bt[smallest]);

sum_wait+=time-at[smallest]-bt[smallest];

sum_turnaround+=time-at[smallest];

bt[smallest]=0;

}

printf("\nAvg waiting time = %f\n",sum_wait*1.0/n);

printf("Avg turnaround time = %f",sum_turnaround*1.0/n);

return 0;

} Output:--

Page 16: O.s. lab all_experimets

Experiment No.=5 Aim:-- WAP simulate Round Robin C.P.U. Scheduling algorithm.

Page 17: O.s. lab all_experimets

#include<stdio.h>

#include<conio.h>

int main()

{

int i,j,n,time,remain,flag=0,ts;

int sum_wait=0,sum_turnaround=0,at[10],bt[10],rt[10];

printf("Enter no of Processes : ");

scanf("%d",&n);

clrscr();

remain=n;

for(i=0;i<n;i++){

printf("Enter arrival time and burst time for Process P%d :",i+1);

scanf("%d",&at[i]);

scanf("%d",&bt[i]);

rt[i]=bt[i];

}

printf("Enter time slice");

scanf("%d",&ts);

printf("\n\nProcess\t|Turnaround time|waiting time\n\n");

for(time=0,i=0;remain!=0;)

{

if(rt[i]<=ts && rt[i]>0){

time+=rt[i];

rt[i]=0;

flag=1;

}

else if(rt[i]>0){

rt[i]-=ts;

time+=ts;

}

if(rt[i]==0 && flag==1)

{

remain--;

printf("P[%d]\t|\t%d\t|\t%d\n",i+1,time-at[i],time-at[i]-bt[i]);

sum_wait+=time-at[i]-bt[i];

sum_turnaround+=time-at[i];

flag=0;

}if(i==n-1)

i=0;

else if(at[i+1]<=time)

i++;

}

printf("\nAvg sum_wait = %f\n",sum_wait*1.0/n);

printf("Avg sum_turnaround = %f",sum_turnaround*1.0/n);

return 0;

}

Output:--

Page 18: O.s. lab all_experimets

Experiment No.=6

Aim:-- WAP in C Banker’s algorithm for Deadlock Avoidance.

Page 19: O.s. lab all_experimets

#include<stdio.h> #include<conio.h> int max[100][100]; int alloc[100][100]; int need[100][100]; int avail[100]; int n,r; void input(); void show(); void cal(); int main() {

int i,j; printf("********** Baner's Algo ************\n"); input(); show(); cal(); getch(); return 0; } void input() { int i,j;

printf("Enter the no of Processes\t"); scanf("%d",&n); printf("Enter the no of resources instances\t"); scanf("%d",&r); printf("Enter the Max Matrix\n"); for(i=0;i<n;i++) { for(j=0;j<r;j++)

{ scanf("%d",&max[i][j]); }}

printf("Enter the Allocation Matrix\n"); for(i=0;i<n;i++) { for(j=0;j<r;j++) { scanf("%d",&alloc[i][j]); }} printf("Enter the available Resources\n"); for(j=0;j<r;j++)

Page 20: O.s. lab all_experimets

{ scanf("%d",&avail[j]); }} void show() { int i,j; printf("Process\t Allocation\t Max\t Available\t"); for(i=0;i<n;i++) { printf("\nP%d\t ",i+1); for(j=0;j<r;j++) {

printf("%d ",alloc[i][j]); } printf("\t"); for(j=0;j<r;j++) { printf("%d ",max[i][j]); } printf("\t"); if(i==0) { for(j=0;j<r;j++) printf("%d ",avail[j]);

}}} void cal() { int finish[100],temp,need[100][100],flag=1,k,c1=0; int safe[100]; int i,j; for(i=0;i<n;i++) { finish[i]=0;

} for(i=0;i<n;i++) {

for(j=0;j<r;j++) { need[i][j]=max[i][j]-alloc[i][j]; }} printf("\n"); while(flag) { flag=0; for(i=0;i<n;i++) {

Page 21: O.s. lab all_experimets

int c=0; for(j=0;j<r;j++) { if((finish[i]==0)&&(need[i][j]<=avail[j])) { c++; if(c==r) { for(k=0;k<r;k++) { avail[k]+=alloc[i][j]; finish[i]=1; flag=1;

} printf("P%d->",i); if(finish[i]==1) { i=n; }}}}}} for(i=0;i<n;i++) { if(finish[i]==1) { c1++; }

else { printf("P%d->",i); }} if(c1==n) { printf("\n The system is in safe state"); } else

{ printf("\n Process are in dead lock"); printf("\n System is in unsafe state");

} }

Output:--

Page 22: O.s. lab all_experimets

Experiment No.=7

Aim:-- WAP in C to implement FIFO page replacement algorithm. #include<stdio.h>

Page 23: O.s. lab all_experimets

#include<conio.h> int main() { int i,j,n,a[50],frame[10],no,k,avail,count=0; clrscr(); printf("ENTER THE NUMBER OF PAGES:"); scanf("%d",&n); printf("\n ENTER THE PAGE NUMBER :"); for(i=1;i<=n;i++) scanf("%d",&a[i]); printf("\n ENTER THE NUMBER OF FRAMES :"); scanf("%d",&no);

for(i=0;i<no;i++) frame[i]= -1; j=0; printf("\tref string\t page frames\n"); for(i=1;i<=n;i++) { printf("%d\t\t",a[i]); avail=0; for(k=0;k<no;k++) if(frame[k]==a[i]) avail=1;

if (avail==0) { frame[j]=a[i]; j=(j+1)%no; count++; for(k=0;k<no;k++) printf("%d\t",frame[k]); }

printf("\n"); } printf("Page Fault Is %d",count);

getch(); return 0; }

Output:--

Page 24: O.s. lab all_experimets

Experiment No.=8

Aim:-- WAP in C to implement LRU page replacement algorithm.

Page 25: O.s. lab all_experimets

#include<stdio.h> #include<conio.h> main() { int q[20],p[50],c=0,c1,d,f,i,j,k=0,n,r,t,b[20],c2[20]; clrscr(); printf("Enter no of pages:"); scanf("%d",&n); printf("Enter the reference string:"); for(i=0;i<n;i++) scanf("%d",&p[i]); printf("Enter no of frames:"); scanf("%d",&f); q[k]=p[k]; printf("\n\t%d\n",q[k]); c++; k++; for(i=1;i<n;i++) { c1=0; for(j=0;j<f;j++) { if(p[i]!=q[j]) c1++; } if(c1==f) { c++; if(k<f) { q[k]=p[i]; k++; for(j=0;j<k;j++) printf("\t%d",q[j]); printf("\n"); } else { for(r=0;r<f;r++) { c2[r]=0; for(j=i-1;j<n;j--) { if(q[r]!=p[j])

Page 26: O.s. lab all_experimets

c2[r]++; else break; } } for(r=0;r<f;r++) b[r]=c2[r]; for(r=0;r<f;r++) { for(j=r;j<f;j++) { if(b[r]<b[j]) { t=b[r]; b[r]=b[j]; b[j]=t; } } } for(r=0;r<f;r++) { if(c2[r]==b[0]) q[r]=p[i]; printf("\t%d",q[r]); } printf("\n"); } } } printf("\nThe no of page faults is %d",c); getch(); return 0; }

Output:--

Page 27: O.s. lab all_experimets