Sie sind auf Seite 1von 67

INDEX

Operating System
S.NO.
1 2

Practical File
TOPIC SIGNATURE

To study hardware and software requirements for the operating system. Write a program to calculate average waiting time and turnaround time for the processes using FCFS CPU scheduling algorithm. Write a program to calculate average waiting time for the processes using Priority CPU scheduling. Write a program to calculate average waiting time for the processes using SJF CPU scheduling. Write a program to implement compaction & count the number of data memory movements during process. Write a program to calculate average waiting time for the processes using Round Robin CPU scheduling. Write a program to implement Bankers Algorithm. Write a program to implement the deadlock detection. Write a program to implement the worst fit, best fit & first fit for contiguous memory allocation. Study of system calls and various operating system management services in UNIX.

3 4 5 6 7 8 9 10

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 02

S/W LAB (AT)

Program No.-1

What is an Operating System?


An operating system (OS) is an interface between hardware and user which is responsible for the management and coordination of activities and the sharing of the resources of the computer that acts as a host for computing applications run on the machine. Software that controls the allocation and usage of hardware resources such as memory, CPU time, disk space, and input and output devices. The foundation software of a machine; that which schedules tasks, allocates storage, and presents a default interface to the user between applications.

Operating System Functions


It manages the hardware and software resources of the system. In a desktop computer, these resources include the processor, memory, disk space and many more (On a cell phone, they include the keypad, the screen, the address book, etc.) It provides a stable, consistent way for applications to deal with the hardware without having to know all the details of the hardware.

Some of the Operating Systems


MS-DOS Microsoft Windows Mac OS Unix and Unix-like operating systems Linux and GNU Google Chrome OS

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 03

S/W LAB (AT)

MS-DOS
The term DOS can refer to any Operating System, but it is most often used as shorthand for MSDOS (Microsoft disk operating system). Originally Developed by Microsoft for IBM, MS-DOS was the standard Operating System for IBM-Compatible personal computers

Company / developer Programmed in OS family Working state Source model Initial release Latest stable release Available language(s) Available programming languages(s) Supported platforms Kernel type Default user interface License

= = = = = = = = = = = = =

Microsoft Corporation Assembly language DOS Discontinued/Historic Closed source 1981 8.0 / September 14, 2000; 10 years ago Multilanguage C, Pascal, QBasic, Batch, etc. x86 Monolithic kernel Command-line interface, Text user interface Proprietary

Version Information
Date 1981 Aug. 1981 June Version MS-DOS 1.0, formerly QDOS/86-DOS, can use at maximum 128 kbyte RAM, FAT established MS-DOS 1.10,

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA 1982 Aug. 1983 March

PAGE NO 04

S/W LAB (AT)

MS-DOS 1.25, support for double-density floppy disks MS-DOS 2.0, support for IBM 10 mbyte hard disk, directorys and DD 5.25" floppy disk drives with up to 360 Kbyte MS-DOS 2.11, extended character sets MS-DOS 3.0, support for high density floppy disk drives with 1.2 mbyte and hard disk devices with 32 mbyte capacity MS-DOS 3.1, first time with network support MS-DOS 3.2 MS-DOS 3.21 MS-DOS 3.3, extended for IBM's PS/2 computer, supports now bigger 3.5" harddisk drives and floppy disk drives, multiple partitions, character sets for different languages MS-DOS 4.0, XMS support, partitions with up to 2 gbyte, graphical shell, bug fixes MS-DOS 4.01, supports multiple partitions bigger than 32 mbyte, bug fixes MS-DOS 5.0, Major Release MS-DOS 5.0a, bug fixes for Undelete and Check disk MS-DOS 6.0, Competition to Novell's DR-DOS 6, DoubleSpace, Anti-Virus program, Defrag, Move command, improved MSBACKUP and several boot configurations, memory optimizer MEMMAKER, DOS Shell is delivered separately on floppy disks

1983 Dec. 1984 Aug.

1984 1985 1985 1987 April

1988 July 1988 Nov. 1991 June 1992 1993 Aug.

1993 Nov.

MS-DOS 6.2, DoubleSpace becomes incompatible to the previous version, Scandisk, improved of DISKCOPY and Smart Drive

1994 March

MS-DOS 6.21, because of law conflict with Stac Electronics DoubleSpace is removed from MS DOS

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA 1994 May

PAGE NO 05

S/W LAB (AT)

MS-DOS 6.22, Microsoft licenses double disk of VertiSoft Systems and designates it in DriveSpace, last official standalone version

1995 Aug.

MS-DOS 7.0, MS-DOS component for Windows 95, LFS support through VFAT, more DOS programs are delivered on the Setup CD-ROM in the "oldmsdos" directory

1996 Aug.

MS-DOS 7.10, MS-DOS component for Windows 95 B and higher, supports the first time FAT 32 hard disks MS-DOS 8.0, MS-DOS component for Windows ME, last MS-DOS version

2000

Hardware & Software Requirements


At least a 486DX33 with 16MB RAM is required. A Pentium or Pentium Pro and more main memory are recommended. A 386 or a system with 8mb or less memory is an insufficient configuration. There are no specific requirements concerning networks cards, disk types, or CD rom equipment of course the more powerful, the better. Depending on the packages installed, a disk space of 20-55MB on a HPFS formatted partition (or a JFS, NFS or ext2fs partition natively allowing long filenames) is required. XFree86/OS2 will not run on FAT partitions. You need a video card that is supported by XFree86. Refer to the general README document for a list of supported cards. Note that the sets of video cards supported XFree86 as well, and vice versa. XFree86 does not use the video services of the OS/2 operating system.

Required software
Any version of Warp 3 with atleast fixpack 17 or Wrap 4 is required XFree86/OS2-3.3.6 may use a local named pipe connection or a TTCP/IP based network connection.

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 06

S/W LAB (AT)

1. Wrap comes with the Internet Access Kit (ACK), which is sufficient. Wrap connect and Wrap Server come with a full version of TCP/IP (3.0). Use of this software is preferred over IK then. 2. Wrap 4 comes with TCP/IP 4.0 which should also work. 3. There are reports that with EEMX 0.9 fix 4, you can also use the new 32 bit IBM TCP/IP 4. Product. o The old IBM TCP/IP 2.0 that comes with the IBM PMX product may be used with Wrap as well although it is no longer supported by IBM.. Please see version of TCP/I{ such as FTPs DFCs or programming TCP/IP versions, as well as IBM TCP/IP 1.X are not supported. Nor does any networking support from DOS (packet drivers, wwsck), Netware or NetBOS work and I wont do provide support for that in the future. o If you want to write or port applications for XFree86 you are encourages to do so. You will need a complete installation of EMX/gee 0.9C flx4 or later for doing so, Neither the second (obsolete) implementation of gee nor an commercial package including Cset/2 VAX++, BorlandCC++/OS2, Watcom C++, MetawareC and other, is suitable for porting because various parts of the XDLLs rely on certain features only present with EMX.

Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft. Microsoft introduced an operating environment named Windows on November 20, 1985 Microsoft Windows came to dominate the world's personal computer market. The most recent client version of Windows is Windows 7; the most recent server version is Windows Server 2008 R2; the most recent mobile version is Windows Phone 7.

Windows NT family
The NT family of Windows systems was fashioned and marketed for higher reliability business use. The first release was NT 3.1 (1993), numbered "3.1" to match the consumer Windows version, which was followed by NT 3.5 (1994), NT 3.51 (1995), NT 4.0 (1996), and Windows 2000, which is the last NT-based Windows release that does not include Microsoft Product Activation. Windows NT 4.0 was the first in this line to implement the "Windows 95" user interface (and the first to include Windows 95s built-in 32-bit runtimes)

Basic Details
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 07

S/W LAB (AT)

Programmed in Source model Initial release Latest stable release

= = = =

C, C++ and Assembly

language

Closed source / Shared source 27 July 1993 (as Windows NT 3.1) Windows 7, Windows Server 2008 R2 NT 6.1 (Build 7601: Service Pack 1) (February 22, 2011; 6 months ago)

Latest unstable release Update method Supported platform

= = =

Windows 8 NT 6.2 (Build 8094) Windows Update IA-32, x86-64, Alpha, MIPS, Power PCM ARM, Itanium

Kernel type Default user interface License

= = =

Hybrid Graphical (Windows Explorer) MS-EULA

Hardware requirements
The minimum hardware specification required to run each release of the professional workstation version of Windows NT has been fairly slow-moving until the 6.0 Vista releases, which requires a minimum of 15 GB of free disk space, a 10-fold increase in free disk space alone over the previous version.

Windows NT desktop (x86) minimum hardware requirements NT version NT 3.1 NT 3.1 Advanced Server CPU 386, 25 MHz RAM 12 MB 16 MB Free disk space 90 MB

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA NT 3.5 Workstation NT 3.5 Server NT 3.51 Workstation NT 3.51 Server NT 4.0 Workstation NT 4.0 Server 2000 Professional 2000 Server XP Server 2003 Vista 7 386, 25 MHz 386, 25 MHz 486, 25 MHz Pentium, 133 MHz Pentium, 233 MHz Pentium, 133 MHz Pentium III, 800 MHz Pentium III, 1 GHz

PAGE NO 08
90 MB 90 MB 124 MB 650 MB 1.5 GB 1.5 GB 15 GB 16 GB

S/W LAB (AT)


12 MB 16 MB 12 MB 16 MB 12 MB 16 MB 32 MB 128 MB 64 MB* 128 MB 512 MB** 512 MB**

*Windows XP can be run at 64 MB RAM. Some features require 128 MB RAM. ** Windows Vista and 7 can be run from 512 MB but Microsoft recommends 1 GB.

MAC OS
Mac OS is a series of graphical user interface-based operating systems developed by Apple Inc. (formerly Apple Computer, Inc.) for their Macintosh line of computer systems. The Macintosh user experience is credited with popularizing the graphical user interface. The original form of what Apple would later name the "Mac OS" was the integral and unnamed system software first introduced in 1984 with the original Macintosh, usually referred to simply as the System software.

Company/ Developer OS family

= =

Apple Inc Mac OS (System 17, Mac OS 89) Unix (Mac OS X)

Working state Source model

= =

Publically released Proprietary software (with open source components 10.7.1 [+/] 10.7.2 "Lion" build 11C48 [+/] Proprietary EULA

Latest stable release Latest unstable release License

= = =

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 09

S/W LAB (AT)

System requirements
Apple states the following basic Leopard system requirements, although, for some specific applications and actions (such as iChat backdrops) an Intel processor is required: Processor must be any Intel, PowerPC G5 or G4 (867 MHz and faster) DVD drive (for installation of the operating system) At least 512 MB of RAM (additional RAM (1 GB) is recommended for development purposes) At least 9 GB of disk space available. Leopards retail version was not released in separate versions for each type of processor, but instead consisted of one universal release that could run on both PowerPC and Intel processors. However, the install discs that ship with Intel-based Macs only contain Intel binaries. Processor type and speed are checked during installation and installation halted if insufficient; however, Leopard will run on slower G4 processor machines (e.g., a 733mhz Quicksilver) if the installation is performed on a supported Mac and its hard-drive then moved to a slower/unsupported one (the drive may either be an internal mechanism or a Fire wire external)

MAC OS VERSIONS
Version Rhapsody Developer Release Mac OS X Server 1.0 Public Beta 10.0 10.1 10.2 10.3 10.4 Codename Grail1Z4 / Titan1U Hera Date Announced Release Date August 31, 1997 March 16, 1999 Most Recent Version May 14, 1998 1.2v3 2000) (October 27,

Kodiak Cheetah Puma Jaguar Panther Tiger July 18, 2001[69] May 6, 2002[70] June 23, 2003[71] May 4, 2004[72]

September 13, 2000 March 24, 2001 September 25, 2001 August 24, 2002 October 24, 2003 April 29, 2005 10.0.4 (June 22, 2001) 10.1.5 (June 6, 2002) 10.2.8 2003) (October 3,

10.3.9 (April 15, 2005) 10.4.11 (November 14, 2007)

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA 10.5 10.6 10.7 Leopard Snow Leopard Lion

PAGE NO 010
10.5.8 (August 5, 2009) 10.6.8 (June 23, 2011) 10.7.1 2011) (August 16,

S/W LAB (AT)


June 26, 2006[73] June 9, 2008[74] October 2010[75] 20, October 26, 2007 August 28, 2009 July 20, 2011

Unix and Unix-like


Unix (officially trademarked as UNIX, sometimes also written as Unix) is a multitasking, multiuser computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna. The Unix operating system was first developed in assembly language, but by 1973 had been almost entirely recoded in C, greatly facilitating its further development and porting to other hardware. Today's Unix systems are split into various branches, developed over time by AT&T as well as various commercial vendors and non-profit organizations. The second edition of Unix was released on December 6th, 1972. The Open Group, an industry standards consortium, owns the UNIX trademark. Only systems fully compliant with and certified according to the Single UNIX Specification are qualified to use the trademark; others might be called "Unix system-like" or "Unix-like" (though the Open Group disapproves of this term). However, the term "Unix" is often used informally to denote any operating system that closely resembles the trademarked system.

Company / developer Programmed in OS family Working state Source model Initial release Available language(s) Available programming languages(s) Kernel type Default user interface License

= = = = = = = = = = =

Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna at Bell Labs C Unix Active Historically closed source, now some Unix projects (BSD family and Illumos) are open sourced. 1969 English C, C++ Monolithic Command-line interface & Graphical (X Window System) Proprietary

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 011

S/W LAB (AT)

Hardware requirements
Processor: CPU speeds of late model, mid-range to high-end server are recommended. Pentium 4 processor at 2.5 GHz or equivalent at the minimum Physical Memory: 10GB at minimum per Processor Disk Space: 10 GB at a minimum Virtual Memory/ swap memory: this value should be equal to double your physical memory. At minimum, this should be at least equal to your physical memory. File System: the Linux ext3 file system is used by default. Network Connectivity: to use the site across a network, the following elements are required: o Network adapter and connections to a physical network that can carry IP packets o Static IP Address is recommended. Configured fully qualified host name. the server must be able to resolve an IP, Address from its qualified host name to ensure that this is configured correctly, issue the ping command from command line, for example, ping hostname.yaureo.com, where hostname .youreo.com is the fully qualified host name

Free Unix-like operating systems


In 1983, Richard Stallman announced the GNU project, an ambitious effort to create a free software Unix-like system; "free" in that everyone who received a copy would be free to use, study, modify, and redistribute it. The GNU project's own kernel development project, GNU Hurd, had not produced a working kernel, but in 1991 Linus Torvalds released the Linux kernel as free software under the GNU General Public License. In addition to their use in the GNU/Linux operating system, many GNU packages such as the GNU Compiler Collection (and the rest of the GNU toolchain), the GNU C library and the GNU core utilities have gone on to play central roles in other free Unix systems as well. Linux distributions, comprising Linux and large collections of compatible software have become popular both with individual users and in business. Popular distributions include Red Hat Enterprise Linux, Fedora, SUSE Linux Enterprise, openSUSE, Debian GNU/Linux, Ubuntu,

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 012

S/W LAB (AT)

Linux and GNU


Ubuntu, a common GNOME desktop Linux distribution Kubuntu, a common KDE desktop Linux distribution Linux (or GNU/Linux) is a Unix-like operating system that was developed without any actual Unix code, unlike BSD and its variants. Linux can be used on a wide range of devices from supercomputers to wristwatches. The Linux kernel is released under an open source license, so anyone can read and modify its code. It has been modified to run on a large variety of electronics. Although estimates suggest that Linux is used on 1.82% of all personal computers it has been widely adopted for use in servers and embedded systems (such as cell phones). Linux has superseded Unix in most places[which?], and is used on the 10 most powerful supercomputers in the world. The Linux kernel is used in some popular distributions, such as Red Hat, Debian, Ubuntu, Linux Mint and Google's Android. The GNU project is a mass collaboration of programmers who seek to create a completely free and open operating system that was similar to Unix but with completely original code. It was started in 1983 by Richard Stallman, and is responsible for many of the parts of most Linux variants. For this reason, some claim that the combined product of the Linux kernel and the GNU software collection is more correctly called GNU/Linux. Thousands of pieces of software for virtually every operating system are licensed under the GNU General Public License. Meanwhile, the Linux kernel began as a side project of Linus Torvalds, a university student from Finland. In 1991, Torvalds began work on it, and posted information about his project on a newsgroup for computer students and programmers. He received a wave of support and volunteers who ended up creating a full-fledged kernel. Programmers from GNU took notice, and members of both projects worked to integrate the finished GNU parts with the Linux kernel in order to create a full-fledged operating system.

Company / developer Programmed in OS family Working state Source model Latest stable release

Many (trademark owned by Linus Torvalds) Various Unix-like Current Free and open source software Kernel: 3.0.4 (29 August 2011; 13 days ago)

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA Latest unstable release Marketing target Available language(s) Available programming languages(s) Supported platforms

PAGE NO 013

S/W LAB (AT)


Kernel: 3.1-rc4 (29 August 2011; 13 days ago) Desktops, servers, embedded devices Multilingual Many

DEC Alpha, ARM, AVR32, Blackfin, ETRAX CRIS, FR-V, H8/300, Itanium, M32R, m68k, Microblaze, MIPS, MN103, PA-RISC, PowerPC, s390, S+core, SuperH, SPARC, TILE64, Unicore32, x86, Xtensa Monolithic Various Many Many

Kernel type Userland Default user interface License

Hardware Requirements
This system has been run on a 486sx33 with 8 megabytes of ram. It didnt run very It Use Pentium 75 with 16 megs of RAM. LRP distributionrunning off of a floppy with a 6megs of ramsdisk and 10 megs of main memory. Tested it at 700kbit Real VideoStream Through it For over an hour

Google Chrome OS
Chrome is an operating system based on the Linux kernel and designed by Google. Since Chrome OS targets computer users who spend most of their time on the Internet, it is mainly a web browser with no ability to run applications. It relies on Internet applications (or Web apps) used in the web browser to accomplish tasks such as word processing and media viewing, as well as online storage for storing most files. Google Chrome OS is a Linux-based operating system designed by Google to work exclusively with web applications. Google announced the operating system on July 7, 2009 and made it an open source project, called Chromium OS, that November. Unlike Chromium OS, which can be compiled from the downloaded source code, Chrome OS only ships on specific hardware from Google's manufacturing partners. The user interface takes a minimalist approach, resembling that of the Chrome web browser. Since Google Chrome OS is aimed at users who spend most of their computer time on the Internet, the only application on the device is a browser incorporating a media player and a file manager.

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 014

S/W LAB (AT)

Company / developer Programmed in OS family Working state Latest stable release Latest unstable release Update method Package manager Supported platforms Kernel type Default user interface License

= = = = = = = = = =

Google Inc. C, C++ Unix-like Preinstalled on specific hardware (Chromebooks) 0.13.587.135 (Stable) September 7, 2011; 0.14.811.89 (Beta) September 6, 2011; 0.15.1011.0 (Dev) September 9, 2011; Rolling release Portage x86, ARM Monolithic (Ubuntu[1] Linux kernel) Graphical interface based on the Google Chrome Browser Google Chrome OS Terms of Service

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 015

S/W LAB (AT)

Program No.-2
Aim: Write a program to calculate average waiting time and turnaround time for the processes using FCFS CPU scheduling algorithm.
#include<stdio.h> #include<conio.h> void main() { int i,bt[20],wt[30],at[20],sum=0,sum1=0,n,ta[20]; int c[20],avg,avg1; clrscr(); printf("enter the number of processes"); scanf("%d",&n); for(i=0;i<n;i++) { printf("enter the process"); scanf("%d",&c[i]); printf("enter the burst time for this"); scanf("%d",&bt[i]); printf("enter the arrival time"); scanf("%d",&at[i]);

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 016

S/W LAB (AT)

}wt[0]=0; ta[0]=bt[0]; for(i=1;i<n;i++) { wt[i]=(wt[i-1]+bt[i-1]+at[i-1])-at[i]; ta[i]=(wt[i]+bt[i]); } for(i=0;i<n;i++) { sum=sum+wt[i]; sum1=sum1+ta[i]; } avg=sum/n; avg1=sum1/n; printf("process name\tburst time\tarrival time\twaiting time\tturnaround time\n"); for(i=0;i<n;i++) { printf("%d\t\t%d\t\t%d\t\t%\d\t\t%d",c[i],bt[i],at[i],wt[i],ta[i]); printf("\n"); } printf("average waiting time is %d",avg);
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 017

S/W LAB (AT)

printf("\n"); printf("average turnaround time is%d",avg1); getch(); }

OUTPUT:

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 018

S/W LAB (AT)

Program No.-3
Aim: Write a program to calculate average waiting time for the processes using Priority CPU scheduling.
#include<stdio.h> #include<conio.h> void main() { int a[20],b[20],p[20],w[20],i,j,n,temp1,temp2,temp3,sum=0,avg; clrscr(); printf("enter the number of processes"); scanf("%d",&n); for(i=0;i<n;i++) { printf("enter the process name,it's burst time and it's priority"); scanf("%d%d%d",&a[i],&b[i],&p[i]); } for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { if(p[i]>p[j]) {
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 019

S/W LAB (AT)

temp1=p[i]; temp2=b[i]; temp3=a[i]; p[i]=p[j]; a[i]=a[j]; b[i]=b[j]; p[j]=temp1; b[j]=temp2; a[j]=temp3; } } } w[0]=0; printf("waiting of %d process is %d\n ",a[0],w[0]); for(i=1;i<n;i++) { w[i]=w[i-1]+b[i-1]; printf("waiting time of %d process is %d \n ",a[i],w[i]); } for(i=0;i<n;i++) { printf("\nCPU is allocated to process %d with burst time %d and priority %d",a[i],b[i],p[i]);

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 020

S/W LAB (AT)

} for(i=0;i<n;i++) { sum=sum+w[i]; } avg=sum/n; printf("\naverage waiting time is %d", avg); getch(); }

OUTPUT:

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 021

S/W LAB (AT)

Program No.-4
Aim: Write a program to calculate average waiting time for the processes using SJF CPU scheduling.
#include<stdio.h> #include<conio.h> void main() { int a[20],b[20],w[20],i,j,n,temp1,temp2,sum=0,avg; clrscr(); printf("enter the number of processes"); scanf("%d",&n); for(i=0;i<n;i++) { printf("enter the process name and it's burst time"); scanf("%d %d",&a[i],&b[i]); } for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { if(b[i]>b[j]) {
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 022

S/W LAB (AT)

temp1=b[i]; temp2=a[i]; b[i]=b[j]; a[i]=a[j]; b[j]=temp1; a[j]=temp2; } } } w[0]=0; printf("waiting time for %d process is %d\n",a[0],w[0]); for(i=1;i<n;i++) { w[i]=w[i-1]+b[i-1]; printf("waiting time for %d process is %d\n",a[i],w[i]); } for(i=0;i<n;i++) { printf("\nCPU is allocated to process %d with burst time %d",a[i],b[i]); } for(i=0;i<n;i++) {

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 023

S/W LAB (AT)

sum=sum+w[i]; } avg=sum/n; printf("\naverage waiting time is %d",avg); getch(); }

OUTPUT:

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 024

S/W LAB (AT)

Program No.-5
Aim: Write a program to implement compaction & count the number of data memory movements during process.
#include<stdio.h> #include<conio.h> void main() { int a[20],i,j,n,temp,n1; int count=0,loc,c=0; clrscr(); printf("enter the number of elements in the array"); scanf("%d",&n); printf("enter the elements of the array"); for(i=0;i<n;i++) { scanf("%d",&a[i]); } printf("enter the no of locations you want to delete"); scanf("%d",&n1); for(i=0;i<n1;i++) { printf("enter the location"); scanf("%d",&loc); a[loc-1]=0; } Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 025

S/W LAB (AT)

for(i=0;i<n;i++) { if(count!=n1) { if(a[i]==0) { for(j=n-1;j>i;j--) { if(a[j]!=0) { temp=a[j]; a[j]=a[i]; a[i]=temp; c=c+1; } } count=count+1; } } } printf("the compacted array is"); for(i=0;i<n;i++) { printf("%d",a[i]); printf("\n"); } Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 026

S/W LAB (AT)

printf("Number of memory movements =%d",c); getch(); }

OUTPUT
enter the number of elements in the array10 enter the elements of the array1 2 3 4 5 6 7 8 9 10 enter the no of locations you want to delete5 enter the location3 enter the location6 enter the location1 enter the location4 enter the location9 The compacted array is2 5 7 8 Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 027

S/W LAB (AT)

10 0 0 0 0 0 Number of memory movements =10

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 028

S/W LAB (AT)

Program No.-6
Aim: Write a program to calculate average waiting time for the processes using Round Robin CPU scheduling.
#include<stdio.h> #include<conio.h> void main() { int a[20],b[20],w[20],c[20],i,n,t,count=0,sum=0,total=0,avg; clrscr(); printf("enter the number of processes"); scanf("%d",&n); printf("enter the time quantum"); scanf("%d",&t); printf("enter the burst time for the following processes"); for(i=1;i<=n;i++) { printf("\np[%d]=",i); scanf("%d",&b[i]); } for(i=1;i<=n;i++) { a[i]=b[i];
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 029

S/W LAB (AT)

total=total+b[i]; } while(count<total) { for(i=1;i<=n;i++) { if(b[i]>=t&&b[i]!=0) { b[i]=b[i]-t; count=count+t; c[i]=count; } else if(t>b[i]&&b[i]!=0) { count=count+b[i]; b[i]=0; c[i]=count; } } for(i=1;i<=n;i++) { w[i]=c[i]-a[i];

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 030

S/W LAB (AT)

} } for(i=1;i<=n;i++) { printf("\nwaiting time for p[%d]=%d",i,w[i]); sum=sum+w[i]; } avg=sum/n; printf("\naverage waiting time is %d",avg); getch(); }

OUTPUT:

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 031

S/W LAB (AT)

Program No-7
Aim: Write a program to implement Bankers Algorithm.
#include<stdio.h> #include<conio.h> void main() { int a[20],rt[20],ins[20],all[20][20],max[20][20],av[20]; int need[20][20],sum[20],finish[20],work[20],n1,n2,i,j,k; int count=0,count1=0,s,q,c=0,sv[20],sv2[20],total[20],p=0; int temp1,temp2,r,req[20][20],m1,m2,m3,l,w=0,w1=0; clrscr(); printf("enter the number of processes,no of resource types"); scanf("%d %d",&n1,&n2); printf("enter the instances present for each type of resources available"); for(i=0;i<n2;i++) { scanf("%d",&ins[i]); sum[i]=0; }

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 032

S/W LAB (AT)

for(i=0;i<n1;i++) { finish[i]=0; total[i]=0; } printf("enter the allocation and max resources for each of the following process"); for(i=0;i<n1;i++) { printf("\np[%d]",i+1); for(j=0;j<n2;j++) { scanf("%d%d",&all[i][j],&max[i][j]); req[i][j]=0; } } clrscr(); for(j=0;j<n2;j++) { for(i=0;i<n1;i++) {
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 033

S/W LAB (AT)

sum[j]=sum[j]+all[i][j]; } } for(i=0;i<n2;i++) { av[i]=ins[i]-sum[i]; } for(i=0;i<n1;i++) { for(j=0;j<n2;j++) { need[i][j]=max[i][j]-all[i][j]; } } printf("need\n"); for(i=0;i<n1;i++) { for(j=0;j<n2;j++) { printf("\t%d",need[i][j]);
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 034

S/W LAB (AT)

} printf("\n"); } for(i=0;i<n1;i++) { for(j=0;j<n2;j++) { total[i]=total[i]+need[i][j]; } } for(i=0;i<n2;i++) { work[i]=av[i]; } printf("Safe sequence is\n"); do { if(c!=n1&&c!=0) { for(i=0;i<n1;i++)
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 035

S/W LAB (AT)

{ if(finish[i]==0) { sv[p]=i; sv2[p]=i; p=p+1; } } for(i=0;i<p-1;i++) { q=i; r=sv[q]; for(j=sv[q+1];q<p-1;q++) { if(total[r]>total[j]) { temp1=sv2[q]; sv2[q]=sv2[q+1]; sv2[q+1]=temp1; temp2=total[r];
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 036

S/W LAB (AT)

total[r]=total[j]; total[j]=temp2; } } } for(s=0;s<p;s++) { count=0; i=sv2[s]; for(j=0;j<n2;j++) { if(need[i][j]<=work[j]) { count=count+1; if(count==n2) { for(k=0;k<n2;k++) { work[k]=work[k]+all[i][k]; finish[i]=1;
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 037

S/W LAB (AT)

} printf("p%d",i+1); } } } c=c+1; } } if(c==0) { count1=0; for(i=0;i<n1;i++) { count=0; for(j=0;j<n2;j++) { //printf("need=%d nd work=%d",need[i][j],work[j]); if(need[i][j]<=work[j]&&finish[i]!=1) { count=count+1;
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 038

S/W LAB (AT)

if(count==n2) { for(k=0;k<n2;k++) { work[k]=work[k]+all[i][k]; //printf("\n\t%d",work[k]); finish[i]=1; } printf("p%d",i+1); c=c+1; } } } } } for(i=0;i<n1;i++) { if(finish[i]==1) { count1=count1+1;
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 039

S/W LAB (AT)

} } } while(count1!=n1); printf("\nwork"); for(i=0;i<n2;i++) { printf("\n%d",work[i]); } printf("do u want to request more resources for processes enter 1 for yes and 2 for no"); scanf("%d",&l); if(l==1) { printf(" and for hw many resource types"); scanf("%d",&r); for(i=0;i<r;i++) { printf("enter the no of instances required for the corresponding no of resource type and the process no."); scanf("%d%d%d",&m1,&m2,&m3);

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 040

S/W LAB (AT)

req[m3][m2]=m1; } for(i=m3;i<n1;i++) { for(j=0;j<n2;j++) { if(req[i][j]<=need[i][j]) { if(req[i][j]<=av[j]) { w=1; } w1=1; } } } if(w==1) { printf("request allocated"); }
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 041

S/W LAB (AT)

else printf("request rejected"); if(w1==1) printf(" "); else printf("request exceeded its maximum claim"); } if(l==2) { exit(0); } getch(); }

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 042

S/W LAB (AT)

OUTPUT:

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 043

S/W LAB (AT)

Program No-8
Aim: Write a program to implement the deadlock detection.
#include<stdio.h> #include<conio.h> void main() { int ins[20],all[20][20],av[20]; int sum[20],finish[20],work[20],n1,n2,i,j,k; int count=0,count1=0,s,q,c=0,sv[20],sv2[20],total[20],p=0; int temp1,temp2,r,req[20][20],m1,m2,m3,l,flag=0,flag2; clrscr(); printf("enter the number of processes,no of resource types"); scanf("%d %d",&n1,&n2); printf("enter the instances present for each type of resources available"); for(i=0;i<n2;i++) { scanf("%d",&ins[i]); sum[i]=0; }

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 044

S/W LAB (AT)

for(i=0;i<n1;i++) { finish[i]=0; total[i]=0; } printf("enter the allocation and request resources for each of the following process"); for(i=0;i<n1;i++) { printf("\np[%d]",i+1); for(j=0;j<n2;j++) { scanf("%d%d",&all[i][j],&req[i][j]); } } for(j=0;j<n2;j++) { for(i=0;i<n1;i++) { sum[j]=sum[j]+all[i][j]; }
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 045

S/W LAB (AT)

} for(i=0;i<n2;i++) { av[i]=ins[i]-sum[i]; } for(i=0;i<n1;i++) { for(j=0;j<n2;j++) { total[i]=total[i]+req[i][j]; } } for(i=0;i<n2;i++) { work[i]=av[i]; } printf("request satisfied for\n"); do { if(c!=n1&&c!=0)
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 046

S/W LAB (AT)

{ flag=1; for(i=0;i<n1;i++) { if(finish[i]==0) { sv[p]=i; sv2[p]=i; p=p+1; } } for(i=0;i<p-1;i++) { q=i; r=sv[q]; for(j=sv[q+1];q<p-1;q++) { if(total[r]>total[j]) { temp1=sv2[q];
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 047

S/W LAB (AT)

sv2[q]=sv2[q+1]; sv2[q+1]=temp1; temp2=total[r]; total[r]=total[j]; total[j]=temp2; } } } for(s=0;s<p;s++) { count=0;\ i=sv2[s]; for(j=0;j<n2;j++) { if(req[i][j]<=work[j]) { count=count+1; if(count==n2) { for(k=0;k<n2;k++)
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 048

S/W LAB (AT)

{ work[k]=work[k]+all[i][k]; finish[i]=1; } printf("p%d",i+1); } } } c=c+1; } } if(c==0) { count1=0; for(i=0;i<n1;i++) { count=0; for(j=0;j<n2;j++) { if(req[i][j]<=work[j]&&finish[i]!=1)
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 049

S/W LAB (AT)

{ count=count+1; if(count==n2) { for(k=0;k<n2;k++) { work[k]=work[k]+all[i][k]; finish[i]=1; } printf("p%d",i+1); c=c+1; } } } } } for(i=0;i<n1;i++) { if(finish[i]==1) {


Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 050

S/W LAB (AT)

count1=count1+1; } } } while(count1!=n1&&flag==0); for(i=0;i<n1;i++) { if(finish[i]==1) { count1=count1+1; } else { printf("\nSystem is in deadlock state involving process"); printf("%d",i+1); } } getch(); }

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 051

S/W LAB (AT)

OUTPUT:

Program No-9
Aim: Write a program to implement the worst fit, best fit & first fit for contiguous memory allocation.
#include<stdio.h>
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 052

S/W LAB (AT)

#include<conio.h> void main() { int part[5]; int min[5]; int a,n,i,j,y,temp,max,z=0,large=0; char x; clrscr(); printf("enter memory partition of memory in order in K(only 5)"); for(i=0;i<5;i++) { scanf("%d",&part[i]); } clrscr(); printf("given memory partition of memory in order\n"); for(i=0;i<5;i++) { printf("%dK\n",part[i]); } printf("enter size of the file");
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 053

S/W LAB (AT)

scanf("%d",&a); for(i=0;i<5;i++) { if(large<part[i]) { large=part[i]; } } max=large; if(a>max) printf("size of file is greater than the max. partition\nhence cannot be allocated to any partition\n"); if(a<=max) { printf("enter the no. that you want to apply\n"); printf("1.First fit\n2.Best fit\n3.Worst fit\n"); scanf("%d",&n); switch(n) { case 1:for(i=0;i<5;i++)

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 054

S/W LAB (AT)

{ if(a<=part[i]) { printf("file is allocated to %d partition of memory",part[i]); break; } } break; case 2:for(i=0;i<5;i++) { for(j=i+1;j<5;j++) { if(part[i]>part[j]) { temp=part[i]; part[i]=part[j]; part[j]=temp; } } }
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 055

S/W LAB (AT)

max=part[4]; for(i=0;i<5;i++) { if(a<=part[i]) { min[z]=part[i]; z++; } } for(i=0;i<y;i++) { for(j=i+1;i<y;j++) { if(min[i]>min[j]) { temp=min[i]; min[i]=min[j]; min[j]=temp; } }
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 056

S/W LAB (AT)

} printf("file is allocated to %dk partition of memory",min[i]); break; case 3: printf("file is allocated to %dk partition of memory",max); break; default: printf("invalid input"); } } getch(); }

OUTPUT:

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 057

S/W LAB (AT)

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 058

S/W LAB (AT)

Program No-10
Aim: Study of system calls and various operating system management services in UNIX.
System Calls provide the interface between a process and the operating system. These calls are generally available as assembly language instructions, and are usually listed in the manuals used by assembly language programmers. Some systems may allow system calls to be made directly from a higher level language program, in which case calls normally resemble predefined function or subroutine call. They may generate a call to a special run time routine that makes the system call. System calls are functions that a programmer can call which require the services of their operating system. Usually they involve access to some data that users must not be permitted to corrupt or even change. In UNIX there are various System Calls out of which some are listed below: System calls for low level file I/O create(name, permissions) open(name, mode) close(fd) unlink(fd) read(fd, buffer, n_to_read) write(fd, buffer, n_to_write) System Calls for process control fork() wait()
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 059

S/W LAB (AT)

exec() exit() signal(sig, handler) kill(sig, pid)

The brief description of these System Calls is as follows: 1. creat(name, permissions) : Creating a new File int fd = creat(path,mode) char *path - the name/path of the (new) file int mode - permissions for the new file int fd - returns a file descriptor

file is created if it doesnt exist if it already exists, acts like an open for writing negative return on failure mode sets the initial permissions, e.g.

mode = S_RWXUSR | S_IRGRP | S_IXGRP | S_IXOTH read/write/execute for user (S_RWXUSR) read/execute for group (S_IRGRP | S_IXGRP) execute only for others (S_IXOTH) when created, file descriptor is open for writing even if permissions do not include write access
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 060

S/W LAB (AT)

alternative - use open with special flags: int fd = open( path, O_WRONLY|O_CREAT|O_TRUNC, mode ) O_CREAT flag says create if it doesnt exist

2.

open(name, mode) : Opening a File int fd = open(name,flags) char *name int flags int fd - name of the file to open - read/write/append etc. - returns a file descriptor

in simple use flags is one of: O_RDONLY - read only (0) O_WRONLY - write only (1) O_RDWR - read and write (2)

negative result on failure - file doesnt exist - do not have permissions

3. close(fd): Closing a file closing files is simpler! int res = close(fd) int fd
Name

- an open file descriptor


Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 061

S/W LAB (AT)

int ret - returns:

0 -1

OK failed

4.

unlink(fd) : Deleting files UNIX rm command deletes files it uses the unlink system call int res = unlink(path) char *path - the name/path of the file to remove int mode - permissions for the new file int res - returns an integer 0 - OK -1 - fail

doesnt necessarily delete file but neither does rm UNIX filenames are pointers to the file there may be more than one pointer

5. read(fd, buffer, n_to_read) : Reading a File: ret = read(fd,buff,len) int fd char *buff int len int ret
Name

- a file descriptor (int), open for reading - buffer in which to put chars - maximum number of bytes to read - returns actual number read
Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 062

S/W LAB (AT)

ret is 0 at end of file, negative for error

6. write(fd, buffer, n_to_write) : Writing into the File ret = write(fd,buff,len) int fd - a file descriptor (int), open for writing

char *buff - buffer from which to get chars int len int ret - number of bytes to write - returns actual number written

ret is negative for error, 0 means end of file ret may be less than len

buff need not be NULL terminated if buff is a C string, use strlen to get its length

Both may return negative after interrupt (signal)

7. fork() : A process in UNIX is created with the fork system call, which creates a copy of the process that invokes it. For Example, when you enter a command at the prompt, the shell first creates a copy of itself. The image is practically identical to the calling process, except for a few parameters like the PID. When a process is forked in this way, the child gets a new PID. The forking is responsible for the multiplication of processes in the system.

8. wait(): The parent then executes the wait system call to keep waiting for the child process to complete. When the child process has completed its execution, it sends a termination signal to the parent. The parent is then free to continue with other functions.

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 063

S/W LAB (AT)

9. exec(): The parent has overwrites the image that it has just created with the copy of the program that has to be executed. This is done with the exec system call, and the parent is said to exec this process. No additional process is created here; the existing program is simply replaced with the new program. This process has the same PID as the child that was just forked.

10. exit() : void exit(int status) program ends! its exit code is set to status available to shell: $? - Bourne shell

$status - C shell

11. signal(sig, handler): Catching Signal default action for signals - some abort the process - some ignored you can do what you like - so long as you catch the signal - and its not SIGKILL (signal 9) write the code that you want run int my_handler()

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 064

S/W LAB (AT)

{ my_flag = 1\n; } use the signal system call to tell UNIX about it signal(SIGQUIT,my_handler); when the signal occurs UNIX calls my_handler when you no longer require a signal to be caught signal(SIGQUIT,SIG_IGN); signal(SIGFPE,SIG_DFL);

12. kill(sig, pid) : You can terminate a process with the kill command. The command uses one or more PIDs as its arguments. kill, by default uses the signal number 15 to terminate the process. The process can be killed with the signal number 9, known as the sure kill signal. This signal cant be generated at the press of the key, so kill lets use the signal number as an option: kill -9 121 # Kills process 121 with signal number 9

OPERATING SYSTEM MANAGEMENT SERVICES IN UNIX


UNIX has been around for many decades, making it the oldest of al file systems used on PC hardware. UNIX file systems are also the most different from the other file systems used on PC.UNIX files are managed with discrete text commands similar to how DOS works. There are graphical UNIX shells as well, but many UNIX users never use them. UNIX file systems use the hierarchical directory structure, with a root directory & nested subdirectories. In UNIX file system every thing is defined virtually as being a file- regular text files are of course files, but so are executable programs, directories, & even hardware devices are mapped to file names. This provides flexibility to programmers & users.

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 065

S/W LAB (AT)

PROCESS MANAGEMENT
UNIX is a multiple-user operating system, with several concurrent programs occupying memory. It is inevitable that two or more programs will want the processor at the same time, so the operating system must carefully schedule them. Thus UNIX contains a dispatcher. The UNIX dispatcher relies on a process table that contains one entry for each process. The entry is allocated when the process is created & freed when the process dies. Each entry contains all the data needed by UNIX when process is not active. Among other things the process table entry indicates whether the process is ready or waiting.

MEMORY MANAGEMENT
One of the numerous takes the UNIX kernel performs while the machine is up to manage memory. In this section we will study related terms as well as some of the basic concepts behind memory management. UNIX OS allows us to use all of the physical memory installed in our systems as well as area of the disk which have been designed for use by the kernel in case of physical memory in sufficient for the takes at hand. Virtual memory is simply the sum of the physical memory & the total swap space assigned by the system administrator at the system installation time. The UNIX kernel divides the memory into manageable chunks called pages. A single page of memory is usually 4096 or 8192 bytes. Memory pages laid down contiguously across the physical & virtual memory. When the kernel is first loaded into memory, it sets aside a certain amount RAM for itself as well as all system & user process: main categories in which RAM is divided are TEXT: to hold the text segments for running process. DATA: to hold the data segments of running process STACK: to hold stack segments of the running process. Shared memory: this is an area of memory, which is available to running programs if they need it.

Name

Roll No.

Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 066

S/W LAB (AT)

When a process starts in UNIX, not all its memory pages are read in from the disk at once. Instead, the kernel load into RAM only a few pages at a time. After the CPU digests these, the next page is requested. If it is not found the in RAM, a page fault occurs, signaling the kernel to load the next few pages from disk into RAM. This is called paging & is a perfectly normally system activity in UNIX.UNIX system uses swapping to swap out until enough memory is not available. Allocation of both main memory & swap space is done first fit. When the size of a process memory image increases a new piece of memory big enough for the whole image is allocate. The memory image is copied, the old space is freed, & the appropriate table is updated.

FILE SYSTEM MANIPULATION


Reading & writing of data on disk file systems is usually buffered. Data are not actually read from disk for every read request made by a user, & they are not return to disk for every write request made by a user. Data pass through buffers their way to & from disks. When a user program opens & reads from a file, more data are actually read from disk then were requested, & the extra data are stored in a buffer. Subsequent read request are fulfilled from the buffer until the buffer is empty. Then, the buffer is filled by another read from the disk. When writing to files, data are written in to the buffer until the buffer fills, & then, the contents of the buffer are written to disk. Buffered I/O has very important implications from disk users. File systems must be properly unmounted to ensure that all data are written to disk. If a CD is popped out of the derived without having firs been unmounted, data that remains in the buffer will be lost. Similarly, if someone turns off the power to a computer without having shutdown the computer, data that remain in output buffers are lost.

DISK ALLOCATION
There are two policies for disk allocation GLOBAL POLICY In this a desired disk block is selected according to nearest cylinder block to head. LOCAL POLICY In this cylinder block is chosen such that rotationally it is closest to the one requested in same cylinder or a block in different cylinder, but cylinder group is same. Of there is no free block in cylinder group, a rehashing is done among all other cylinder groups to find a block. If it still fails then exhaustive search is done.
Name Roll No. Submitted to:-

Advance Technologies
PRACTICAL FILE
CSE-311
GOLPURA, BARWALA

PAGE NO 067

S/W LAB (AT)

PROTECTION
UNIX divides all users in three groups which are owner, group & others. File protection is achieved by associating owner id to each file when created. At that time, the owner specifies access for right to each. Access right to each one can be read write or execute. So with the help of the combination of bits (rwx) right can be given to each one. For example %Is-1abh it display following information -rwxrwxrwx 1 Ashok group2 100 10 JAN 10:12 Ashok1 In this 100 show the file size, Ashok is owner of the file, group1 is a label for several users who have been logically grouped together & associated with a name. In beginning of rwxrwxrwx there is a symbol (-) which is for a regular file, not a directory file. After this is rwxrwxrwx, which is known as access mode of the file. It specifies who can do what with Ashok1 where rwx is repeated three times. The first combination is for the owner, second for the group & third one for others. If one of the permission is denied, a - is placed on the appropriate letter. For rw means read &write but no execute, rx means read & execute but no write.

Name

Roll No.

Submitted to:-

Das könnte Ihnen auch gefallen