0% found this document useful (0 votes)
13 views

OS Final Record

Uploaded by

sulochanat7851
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

OS Final Record

Uploaded by

sulochanat7851
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 48

CS3461 OPERATING SYSTEMS LABORATORY LTPC

0 0 3 1.5
COURSE OBJECTIVES:

1. To install windows operating systems.


2. To understand the basics of Unix command and shell programming.
3. To implement various CPU scheduling algorithms.
4. To implement Deadlock Avoidance and Deadlock Detection Algorithms
5. To implement Page Replacement Algorithms
6. To implement various memory allocation methods.
7. To be familiar with File Organization and File Allocation Strategies.

LIST OF EXPERIMENTS:
1. Installation of windows operating system
2. Illustrate UNIX commands and Shell Programming
3. Process Management using System Calls : Fork, Exit, Getpid, Wait, Close
4. Write C programs to implement the various CPU Scheduling Algorithms
5. Illustrate the inter process communication strategy
6. Implement mutual exclusion by Semaphore
7. Write C programs to avoid Deadlock using Banker's Algorithm
8. Write a C program to Implement Deadlock Detection Algorithm
9. Write C program to implement Threading
10. Implement the paging Technique using C program
11. Write C programs to implement the following Memory Allocation Methods
a. First Fit b. Worst Fit c. Best Fit
12. Write C programs to implement the various Page Replacement Algorithms
13. Write C programs to Implement the various File Organization Techniques
14. Implement the following File Allocation Strategies using C programs
a. Sequential b. Indexed c. Linked
15. Write C programs for the implementation of various disk scheduling algorithms

16. Install any guest operating system like Linux using VMware.
Exp.No:1 INSTALLATION OF WINDOWS OPERATING SYSTEM

AIM:

PROCEDURE:
Steps to install Windows 10 :

Step 1: Download Windows 10 ISO image from http://windows.microsoft.com/en-


us/windows/preview-iso. Read more about Windows 10 technical preview ISO images.

Step 2: Mount the ISO image as a drive or burn it into a DVD. Optionally, you can create a
Windows 10 bootable USB drive.

Step 3: Launch your virtual machine software and create a new virtual machine. You can read
more details on how to install Windows 10 on VMWare Workstation.

Step 4: After you create the virtual machine, follow the steps below to install Windows 10.

Step 5: In the welcome screen, choose your language settings and click the "Next" button to
proceed.
Step 6: Accept the license terms and click "Next" to proceed.

Step 7: In the next step, you have to select the drive to install. If you have multiple drives on
your computer, you will see them all there. Choose the correct drive to install. If you are
installing Windows 10 over an existing Windows, you may install side by side on another
drive.
Step 8: Installer will copy all the necessary files to the computer and continue with the
installation. Depending on your system configuration, it may take a while (10-20 minutes) to
complete the installation.

After successful installation, you will see the Windows welcome screen, which is similar to
the Windows 8 theme.

You will be presented with an option to select the Settings. Unless you want to make custom
configuration, you can choose "Express Settings" and proceed.

In the next step, you will be prompted to select One Drive option. If you don't want to
integrate One Drive storage for this computer, you can Turn Off the One Drive options.

The next step is installing some basic apps for your Windows 10 computer. No intervention
from your side is necessary. Windows will automatically install the apps for you. It may take
several minutes to complete the installation.

As part of installation, you will need to connect your Microsoft account with your OS to
access various services like Microsoft App Store. You will need to use the same Microsoft
account to login to your Windows.
You are all set. In a few minutes, Windows 10 will be configured and will be ready for you to
use. If you encounter any errors or have any suggestions for Microsoft to improve the OS,
don't forget to report them to Microsoft.

RESULT:
EXERCISE 2:ILLUSTRATE UNIX COMMANDS AND SHELL PROGRAMMING
a

alias Create an alias •

apropos Search Help manual pages (man -k)

apt-get Search for and install software packages (Debian/Ubuntu)

aptitude Search for and install software packages (Debian/Ubuntu)

aspell Spell Checker

awk Find and Replace text, database sort/validate/index

b
basename Strip directory and suffix

fromfilenames bash GNU Bourne-

Again SHell

bc Arbitrary precision calculatorlanguage

bg Send to background

bind Set or display readline key and function

bindings• break Exit from a loop •

builtin Run a shell builtin

bzip2 Compress or decompress named file(s)

c
cal Display a calendar

case Conditionally perform a command

cat Concatenate and print (display) the content

offiles cd Change Directory

cfdisk Partition table manipulator for Linux

chattr Change file attributes on a Linux filesystem


chgrp Change group

ownership chmod Change access

permissions chown Change file

owner andgroup

chroot Run a command with a different

rootdirectory chkconfig System services (runlevel)

cksum Print CRC checksum and

bytecounts clear Clear terminal screen

cmp Compare two files

comm Compare two sorted files line by line

command Run a command - ignoring shell

functions continue Resume the next iteration

of a loop

cp Copy one or more files to another

location cron Daemon to execute scheduled

commands crontab Schedule a command to

run at a later time csplit Split a file into

context-determined pieces curl Transfer

data from or to a server

cut Divide a file into several parts

d
date Display or change the date &time

dc Desk Calculator

dd Convert and copy a file, write disk headers,

bootrecords ddrescue Data recovery tool

declare Declare variables and give them

attributes• df Display free disk space

diff Display the differences between

twofiles diff3 Show differences among three files

dig DNS lookup


dir Briefly list directorycontents

dircolors Colour setup for `ls'

dirname Convert a full pathname to just a path

dirs Display list of remembered directories

dmesg Print kernel & driver messages

du Estimate file space usage

echo Display message on screen

egrep Search file(s) for lines that match an extendedexpression

eject Eject removable media

enable Enable and disable builtin shell commands

env Environment variables

eval Evaluate severalcommands/arguments

exec Execute a command

exit Exit the shell

expect Automate arbitrary applications accessed over aterminal

expand Convert tabs to spaces

export Set an environment variable

expr Evaluate expressions

false Do nothing, unsuccessfully

fdformat Low-level format a floppydisk

fdisk Partition table manipulator forLinux

fg Send job to foreground

fgrep Search file(s) for lines that match a fixedstring

file Determine file type

find Search for files that meet a desiredcriteria


fmt Reformat paragraph text

fold Wrap text to fit a specified width.

for Expand words, and execute commands

Format Format disks or tapes

Free Display memory usage

fsck File system consistency check andrepair

ftp File Transfer Protocol

function Define FunctionMacros

fuser Identify/kill the process that is accessing a file

gawk Find and Replace text withinfile(s)

getopts Parse positional parameters

grep Search file(s) for lines that match a givenpattern

groupadd Add a user security group

groupdel Delete a group

groupmod Modify a group

groups Print group names a user is in

gzip Compress or decompress named file(s)

hash Remember the full pathname of a nameargument

head Output the first part of file(s)

Help Display help for a built-in command

history Command History

hostname Print or set system name

iconv Convert the character set of afile


id Print user and group id's
if Conditionally perform acommand

ifconfig Configure a network interface

install Copy files and set attributes

ip Routing, devices and tunnels

jobs List active jobs

join Join lines on a common field

kill Kill a process by specifying its PID

killall Kill processes by name

let Perform arithmetic on shell variables

link Create a link to a file

ln Create a symbolic link to afile

local Create a function variable

locate Find files

logname Print current loginname

logout Exit a login shell

look Display lines beginning with a givenstring

lpc Line printer control program

lpr Off line print

lprint Print a file

lprintd Abort a print job

lprintq List the print queue

ls List information aboutfile(s)\


lsof List open files
m
make Recompile a group ofprograms

man Help manual

mkdir Create new folder(s)

mkfifo Make FIFOs (namedpipes)

mkfile Make a file

mktemp Make a temporary file

more Display output one screen at atime

most Browse or page through a textfile


mount Mount a file system
mtools Manipulate MS-DOS files

mtr Network diagnostics(traceroute/ping)


mv Move or rename files or directories
mmv Mass Move and rename (files)

nc Netcat, read and write data acrossnetworks

netstat Networking connections/stats

nice Set the priority of a command or job

nl Number lines and write files

nohup Run a command immune tohangups

notify-send Send desktopnotifications

nslookup Query Internet name servers interactively

open Open a file in its defaultapplication

op Operator access

passwd Modify a user password

paste Merge lines of files


ping Test a networkconnection

pgrep List processes by name

pkill Kill processes by name

popd Restore the previous value of the

currentdirectory pr Prepare files for printing

printcap Printer capability database

printenv Print environment variables

printf Format and print data

ps Process status

pushd Save and then change the current

directory pv Monitor the progress of data through

apipe

pwd Print Working Directory

q
quota Display disk usage and

limits quotacheck Scan a file system for

diskusage r

ram ram disk device

rar Archive files with compression

rcp Copy files between two machines

read Read a line from standard input

readarray Read from stdin into an array

variable readonly Mark

variables/functions as readonly reboot Reboot

the system

rename Rename files

renice Alter priority of running

processes remsync Synchronize remote files

via email return Exit a shell function


rev Reverse lines of a file

rm Remove files

rmdir Remove folder(s)

screen Multiplex terminal, run remote shells viassh

scp Secure copy (remote file copy)

sdiff Merge two files interactively

sed Stream Editor

select Accept keyboard input

seq Print numericsequences

set Manipulate shell variables andfunctions

Sftp Secure File Transfer Program

shift Shift positionalparameters


shopt Shell Options

shutdown Shutdown or restart linux

sleep Delay for a specifiedtime

slocate Find files

sort Sort text files

source Run commands from a file '.'

split Split a file into fixed-size pieces

ss Socket Statistics

ssh Secure Shell client (remote loginprogram)

su Substitute user identity

sudo Execute a command as anotheruser

sum Print a checksum for a file

suspend Suspend execution of this shell


T

tail Output the last part of file

tar Store, list or extract files in anarchive

tee Redirect output to multiple files

test Evaluate a conditionalexpression

time Measure Program running time

timeout Run a command with a time limit

times User and system times

touch Change file timestamps

top List processes running on the system

tput Set terminal-dependent capabilities, color,position

traceroute Trace Route to Host

trap Execute a command when the shell receives a signal•

tr Translate, squeeze, and/or delete characters

true Do nothing, successfully

tsort Topological sort

tty Print filename of terminal onstdin

type Describe a command

ulimit Limit user resources

umask Users file creation mask

Umount Unmount a device

Unalias Remove an alias

Uniq Uniquify files

Units Convert units from one scale to another

Until Execute commands (until error)

Uptime Show uptime


useradd Create new user account

userdel Delete a user account

usermod Modify user account

users List users currently logged in

V
v Verbosely list directory contents (`ls -l -b')

vdir Verbosely list directory contents (`ls -l -b')

vi Text Editor

vmstat Report virtual memory statistics

w
w Show who is logged on and what they are doing

wait Wait for a process to complete

watch Execute/display a program

periodically wc Print byte, word, and line counts

whereis Search the user's $path, man pages and source files

for a program
which Search the user's $path for a program

file while Execute commands

who Print all usernames currently logged in


whoami Print the current user id and name (`id -
un')
wget Retrieve web pages or files via HTTP, HTTPS or
FTP write Send a message to another user

xargs Execute utility, passing constructed argument


list(s) xdg-open Open a file or URL in the user's preferred

application xz Compress or decompress .xz and .lzma files

yes Print a string until interrupted


zip Package and compress (archive) files.
. Run a command script in the current shell

!! Run the last command again


### Comment / Remark
Exercise 3:Process management using system calls:Fork,Exit,Getpid,Wait,Close.

Program code:

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>

extern int errno;

int main()
{
// if file does not have in directory
// then file foo.txt is created.
int fd = open("foo.txt", O_RDONLY | O_CREAT);

printf("fd = %d\n", fd);

if (fd == -1) {
// print which type of error have in a code
printf("Error Number % d\n", errno);

// print program detail "Success or failure"


perror("Program");
}
return 0;
}

Output:
Exercise 4:CPU Scheduling algorithm:First come first serve

Program code:
#include<stdio.h>
#include<conio.h>
main()
{
int bt[20], wt[20], tat[20], i, n;
float wtavg, tatavg; clrscr();
printf("\nEnter the number of processes -- ");
scanf("%d", &n);
for(i=0;i<n;i++)
{
printf("\nEnter Burst Time for Process %d -- ", i);
scanf("%d", &bt[i]);
}
wt[0] = wtavg = 0;
tat[0] = tatavg = bt[0];
for(i=1;i<n;i++)
{
wt[i] = wt[i-1] +bt[i-1];
tat[i] = tat[i-1] +bt[i];
wtavg = wtavg + wt[i];
tatavg = tatavg + tat[i];
}
printf("\t PROCESS \tBURST TIME \t WAITING TIME\t TURNAROUND TIME\n");
for(i=0;i<n;i++)
printf("\n\t P%d \t\t %d \t\t %d \t\t %d", i, bt[i], wt[i], tat[i]);
printf("\nAverage Waiting Time -- %f", wtavg/n);
printf("\nAverage Turnaround Time -- %f", tatavg/n);
getch();
return 0;
}
Output:
Exercise5:Illustrate the inter process communication strategy

Program code:

#include <stdio.h>

int main(void) {
int i, my_array[8];

for(i=0;i<=20;i++) {
my_array[i] = i+1;
}

for(i=0;i<8;i++) {
printf("%d\n", my_array[i]);
}

return 0;
}

Output:
Exercise 6:Implement mutual exclusion by semaphore.

Program code:

#include<stdio.h>

void main() {
int buffer[10], bufsize, in, out, produce, consume, choice=0;
in = 0;
out = 0;
bufsize = 10;

while(choice != 3) {
printf("\n1. Produce \t 2. Consume \t 3. Exit");
printf("\nEnter your choice: ");
scanf("%d", &choice);

switch(choice) {
case 1:
if((in+1) % bufsize == out) {
printf("\nBuffer is Full");
} else {
printf("\nEnter the value: ");
scanf("%d", &produce);
buffer[in] = produce;
in = (in+1) % bufsize;
}
break;

case 2:
if(in == out) {
printf("\nBuffer is Empty");
} else {
consume = buffer[out];
printf("\nThe consumed value is %d", consume);
out = (out+1) % bufsize;
}
break;
}
}
}

Output:
Exercise 7:Write c program to avoid deadlock using banker’s algorithm.

Program code:

#include<stdio.h>

int main() {
/* array will store at most 5 process with 3 resoures if your process or
resources is greater than 5 and 3 then increase the size of array */
int p, c, count = 0, i, j, alc[5][3], max[5][3], need[5][3], safe[5], available[3], done[5], terminate = 0;
printf("Enter the number of process and resources");
scanf("%d %d", & p, & c);
// p is process and c is diffrent resources
printf("enter allocation of resource of all process %dx%d matrix", p, c);
for (i = 0; i < p; i++) {
for (j = 0; j < c; j++) {
scanf("%d", & alc[i][j]);
}
}
printf("enter the max resource process required %dx%d matrix", p, c);
for (i = 0; i < p; i++) {
for (j = 0; j < c; j++) {
scanf("%d", & max[i][j]);
}
}
printf("enter the available resource");
for (i = 0; i < c; i++)
scanf("%d", & available[i]);

printf("\n need resources matrix are\n");


for (i = 0; i < p; i++) {
for (j = 0; j < c; j++) {
need[i][j] = max[i][j] - alc[i][j];
printf("%d\t", need[i][j]);
}
printf("\n");
}
/* once process execute variable done will stop them for again execution */
for (i = 0; i < p; i++) {
done[i] = 0;
}
while (count < p) {
for (i = 0; i < p; i++) {
if (done[i] == 0) {
for (j = 0; j < c; j++) {
if (need[i][j] > available[j])
break;
}
//when need matrix is not greater then available matrix then if j==c will true
if (j == c) {
safe[count] = i;
done[i] = 1;
/* now process get execute release the resources and add them in available resources */
for (j = 0; j < c; j++) {
available[j] += alc[i][j];
}
count++;
terminate = 0;
} else {
terminate++;
}
}
}
if (terminate == (p - 1)) {
printf("safe sequence does not exist");
break;
}

}
if (terminate != (p - 1)) {
printf("\n available resource after completion\n");
for (i = 0; i < c; i++) {
printf("%d\t", available[i]);
}
printf("\n safe sequence are\n");
for (i = 0; i < p; i++) {
printf("p%d\t", safe[i]);
}
}

return 0;
}
Output:
Exercise 8:Write a c program to implement deadlock detection algorithm.

Program code:
#include<stdio.h>
static int mark[20];
int i,j,np,nr;

int main()
{
int alloc[10][10],request[10][10],avail[10],r[10],w[10];

printf("\nEnter the no of process: ");


scanf("%d",&np);
printf("\nEnter the no of resources: ");
scanf("%d",&nr);
for(i=0;i<nr;i++)
{
printf("\nTotal Amount of the Resource R%d: ",i+1);
scanf("%d",&r[i]);
}

printf("\nEnter the request matrix:");

for(i=0;i<np;i++)
for(j=0;j<nr;j++)
scanf("%d",&request[i][j]);

printf("\nEnter the allocation matrix:");


for(i=0;i<np;i++)
for(j=0;j<nr;j++)
scanf("%d",&alloc[i][j]);
/*Available Resource calculation*/
for(j=0;j<nr;j++)
{
avail[j]=r[j];
for(i=0;i<np;i++)
{
avail[j]-=alloc[i][j];

}
}

//marking processes with zero allocation

for(i=0;i<np;i++)
{
int count=0;
for(j=0;j<nr;j++)
{
if(alloc[i][j]==0)
count++;
else
break;
}
if(count==nr)
mark[i]=1;
}
// initialize W with avail

for(j=0;j<nr;j++)
w[j]=avail[j];

//mark processes with request less than or equal to W


for(i=0;i<np;i++)
{
int canbeprocessed=0;
if(mark[i]!=1)
{
for(j=0;j<nr;j++)
{
if(request[i][j]<=w[j])
canbeprocessed=1;
else
{
canbeprocessed=0;
break;
}
}
if(canbeprocessed)
{
mark[i]=1;

for(j=0;j<nr;j++)
w[j]+=alloc[i][j];
}
}
}

//checking for unmarked processes


int deadlock=0;
for(i=0;i<np;i++)
if(mark[i]!=1)
deadlock=1;

if(deadlock)
printf("\n Deadlock detected");
else
printf("\n No Deadlock possible");
}
Output:
ExNo 9:Write C program to implement threading.

Program code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> // Header file for sleep()
#include <pthread.h>

// Function executed by the thread


void *myThreadFun(void *vargp) {
sleep(1); // Sleep for 1 second
printf("Printing GeeksQuiz from Thread\n");
return NULL;
}

int main() {
pthread_t thread_id;
printf("Before Thread\n");

// Create a new thread


pthread_create(&thread_id, NULL, myThreadFun, NULL);

// Wait for the thread to finish


pthread_join(thread_id, NULL);

printf("After Thread\n");
exit(0);
}
Output:
Exercise 10:Implement the paging technique using c program.

Program code:
#include <stdio.h>
#include <stdlib.h>

#define NUM_FRAMES 4
#define NUM_PAGES 10
#define PAGE_SIZE 1024 // Page size in bytes

int main() {
int frames[NUM_FRAMES] = {-1, -1, -1, -1}; // Represents frames, -1 indicates empty frame
int pages[NUM_PAGES]; // Represents pages
int i, j, page, frame, offset, physical_address;

// Initialize pages with data


for (i = 0; i < NUM_PAGES; i++) {
pages[i] = i * PAGE_SIZE;
}

// Accessing pages
printf("Page\tFrame\tOffset\tPhysical Address\n");
for (i = 0; i < NUM_PAGES; i++) {
page = i;
frame = page % NUM_FRAMES;
offset = page * PAGE_SIZE % PAGE_SIZE;
physical_address = frames[frame] * PAGE_SIZE + offset;

if (frames[frame] == -1) {
frames[frame] = i; // Allocate frame for page
}

printf("%d\t%d\t%d\t%d\n", page, frame, offset, physical_address);


}

return 0;
}

Output:
Exercise11:Write C programs to implement the following memory allocation methods.
Mallac() and free()

Program code:
// Program to calculate the sum of n numbers entered by the user

#include <stdio.h>
#include <stdlib.h>

int main() {
int n, i, *ptr, sum = 0;

printf("Enter number of elements: ");


scanf("%d", &n);

ptr = (int*) malloc(n * sizeof(int));

// if memory cannot be allocated


if(ptr == NULL) {
printf("Error! memory not allocated.");
exit(0);
}

printf("Enter elements: ");


for(i = 0; i < n; ++i) {
scanf("%d", ptr + i);
sum += *(ptr + i);
}

printf("Sum = %d", sum);

// deallocating the memory


free(ptr);

return 0;
}
Output:
Ex No:12 Write C programs to implement the various Page
Replacement Algorithms

Program code:
#include <stdio.h>

//user-defined function
int findLRU(int time[], int n)
{
int i, minimum = time[0], pos = 0;

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


{
if (time[i] < minimum)
{
minimum = time[i];
pos = i;
}
}

return pos;
}

//main function
int main()
{
int no_of_frames, no_of_pages, frames[10], pages[30], counter = 0, time[10], flag1, flag2,
i, j, pos, faults = 0;
printf("Enter number of frames: ");
scanf("%d", &no_of_frames);

printf("Enter number of pages: ");


scanf("%d", &no_of_pages);

printf("Enter reference string: ");

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


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

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


{
frames[i] = -1;
}

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


{
flag1 = flag2 = 0;

for (j = 0; j < no_of_frames; ++j)


{
if (frames[j] == pages[i])
{
counter++;
time[j] = counter;
flag1 = flag2 = 1;
break;
}
}
if (flag1 == 0)
{
for (j = 0; j < no_of_frames; ++j)
{
if (frames[j] == -1)
{
counter++;
faults++;
frames[j] = pages[i];
time[j] = counter;
flag2 = 1;
break;
}
}
}

if (flag2 == 0)
{
pos = findLRU(time, no_of_frames);
counter++;
faults++;
frames[pos] = pages[i];
time[pos] = counter;
}

printf("\n");

for (j = 0; j < no_of_frames; ++j)


{
printf("%d\t", frames[j]);
}
}
printf("\nTotal Page Faults = %d", faults);

return 0;
}
Output:
Ex No:13 Write C programs to Implement the various File Organization
Techniques: Single level directory organization.

Program code:
#include<stdio.h>
struct
{
char dname[10],fname[10][10];
int fcnt;
}dir;
void main()
{
int i,ch;
char f[30];
clrscr();
dir.fcnt = 0;
printf("\nEnter name of directory -- ");
scanf("%s", dir.dname);
while(1)
{
printf("\n\n 1. Create File\t2. Delete File\t3. Search File \n 4. Display Files\t5. Exit\nEnter
your choice -- ");
scanf("%d",&ch);
switch(ch)
{
case 1: printf("\n Enter the name of the file -- ");
scanf("%s",dir.fname[dir.fcnt]);
dir.fcnt++;
break;
case 2: printf("\n Enter the name of the file -- ");
scanf("%s",f);
for(i=0;i<dir.fcnt;i++)
{
if(strcmp(f, dir.fname[i])==0)
{
printf("File %s is deleted ",f);
strcpy(dir.fname[i],dir.fname[dir.fcnt-1]);
break;
}
}
if(i==dir.fcnt)
printf("File %s not found",f);
else
dir.fcnt--;
break;
case 3: printf("\n Enter the name of the file -- ");
scanf("%s",f);
for(i=0;i<dir.fcnt;i++)
{
if(strcmp(f, dir.fname[i])==0)
{
printf("File %s is found ", f);
break;
}
}
if(i==dir.fcnt)
printf("File %s not found",f);
break;
case 4: if(dir.fcnt==0)
printf("\n Directory Empty");
else
{
printf("\n The Files are -- ");
for(i=0;i<dir.fcnt;i++)
printf("\t%s",dir.fname[i]);
}
break;
default: exit(0);
}
}
getch();
}
Output:
Exercise 14:File allocation strategies:sequential

Program code:

#include<stdio.h>
main()
{
int f[50],i,st,j,len,c,k;
clrscr();
for(i=0;i<50;i++)
f[i]=0;
X:
printf("\n Enter the starting block & length of file");
scanf("%d%d",&st,&len);
for(j=st;j<(st+len);j++)
if(f[j]==0)
{
f[j]=1 ;
printf("\n%d->%d",j,f[j]);
}
else
{
printf("Block already allocated");
break;
}
if(j==(st+len))
printf("\n the file is allocated to disk");
printf("\n if u want to enter more files?(y-1/n-0)");
scanf("%d",&c);
if(c==1)
goto X;
else
exit();
getch();
return 0;
}
Output:
Exercise 15: FCFS (First-Come, First-Serve) Disk Scheduling Algorithm:
Program code:
#include<stdio.h>
#include<stdlib.h>
int main()
{
int queue[20],head,n,i;
float seek_time=0;
printf("Enter the size of queue:");
scanf("%d",&n);
printf("Enter the queue elements:");
for(i=0;i<n;i++)
{
scanf("%d",&queue[i]);
}
printf("Enter the head position");
scanf("%d",&head);
for(i=0;i<n;i++){
seek_time+=abs(head-queue[i]);
head=queue[i];
}
printf("Total seek time:%f",seek_time);
return 0;
}
Output:
Ex no:16 Install any guest operating system like Linux using VMware

Program:
Choose Your Preferred Linux OS
You probably know which Linux OS you want to try. Some Linux distros are
particularly suited to running in a VM, but others are not. All 32-bit and 64-bit
distros work in a virtual machine. However, you cannot run Linux distros for
ARM architecture (such as the Raspberry Pi) in VMware.
Should you want to emulate an ARM environment in Windows, try QEMU.

If you don't know which OS to choose, however, you'll find our regularly-
updated list of the best Linux distributions here.

Create Your Linux Virtual Machine


While your Linux ISO downloads, it's a good time to start configuring your
VM. Start by launching VMware Workstation Player. When you're ready to
create a VM:

1. Click Create a New Virtual Machine


2. Select the default option, Installer disc image file (iso)
3. Click Browse to find the ISO file

4. With "guest" OS selected, click Next


5. Select Linux as the Guest operating system type
6. Under Version, scroll through the list and select the OS
7. Click Next to proceed and if necessary, input a Virtual machine
name
8. Confirm the storage Location and change if needed

With the operating system selected and configured, it's time to build the virtual
machine.

9. Under Specify Disk Capacity adjust Maximum disk size if


required (the default should be enough)
10. Select Split virtual disk into multiple files as this makes
moving the VM to a new PC easy
11. Click Next then confirm the details on the next screen
12. If anything seems wrong click Back, otherwise click Finish
Your Linux virtual machine will be added to VMware Workstation Player.

Customize Your Virtual Hardware

In some cases, you might need to customize the virtual machine before
installing Linux. Alternatively, you might install the OS and find there is
something missing.

To fix this, right-click your virtual machine in VMware Workstation Player and
select Settings.
Here, you can tweak the virtual machine's hardware in other ways beyond the
HDD. You have options for the Memory, Processors, Network
Adaptor configuration, and much more.

It's worth taking a look at the Processors screen. In the right-hand pane, you'll
spot a reference to a Virtualization engine. By default, this works automatically,
but for troubleshooting set Intel VT-x or AMD-V, depending on your CPU.

You can address performance issues in the Memory screen. Here you'll spot an
illustration of the suggested RAM size, as well as recommended options for your
virtual machine. It's a good idea to stick to these recommendations.
Going too small will prove a problem, while setting the RAM too high will impact
on your PC's performance, slowing everything from standard system tasks to
running the VM software!

Finally, spare a moment to check the Display settings. Default settings should
be fine but if there is an issue with the display you can toggle 3D acceleration.
Multiple monitors can be used and custom resolution set, but note that some
modes will clash with some desktops.
Click OK to confirm changes, then select the virtual machine and click the
Play button to begin.

You might also like