Posts

Lab. No 9 Virtual Round Robin Best Operating System

Lab. No 9 Virtual Round Robin Virtual- Time Round-Robin (VTRR), a proportional share scheduler that can provide good proportional sharing accuracy with O(1) scheduling overhead. VTRR achieves this by combining the benefits of fair queuing algorithms with a round-robin scheduling mechanism. Unlike many other schedulers, VTRR is simple to implement. VTRR provides accurate proportional share allocation with constant, sub-microsecond scheduling overhead. The scheduling overhead using VTRR is two orders of magnitude less than the standard Linux scheduler for large numbers of clients. Direction: Virtual Round Robinin C++. #include int main() { intcount,j,n,time,remain,flag=0,time_quantum; intwait_time=0,turnaround_time=0,at[10],bt[10],rt[10]; printf("Enter Total Process:\t "); scanf("%d",&n); remain=n; for(count=0;count 0) { time+=rt[count]; rt[count]=0; flag=1; } else if(rt[count]>0) { rt[count]-=time_quantum; time+=time_quantum; } if(rt[coun

Lab. No 8 Shortest Job First Operating System

Lab. No 8 Shortest Job First Shortest-Job-First (SJF) is a non-preemptive discipline in which waiting job (or process) with the smallest estimated run-time-to-completion is run next. In other words, when CPU is available, it is assigned to the process that has smallest next CPU burst. The SJF scheduling is especially appropriate for batch jobs for which the run times are known in advance. Since the SJF scheduling algorithm gives the minimum average time for a given set of processes, it is probably optimal. The SJF algorithm favors short jobs (or processors) at the expense of longer ones. The obvious problem with SJF scheme is that it requires precise knowledge of how long a job or process will run, and this information is not usually available. Like FCFS, SJF is non-preemptive therefore; it is not useful in timesharing environment in which reasonable response time must be guaranteed. Direction: Shortest Job First Algorithm In C++. #include #include void main() { int i, j, n, proce

Lab No 7 Round Robin Algorithm For Operating System

Lab No 7 Round Robin Algorithm Round-Robin is one of the algorithms employed by process and network schedulers incomputing. As the term is generally used, time slices are assigned to each process in equal portions and in circular order, handling all processes without priority (also known as cyclic executive). Round-robin scheduling is simple, easy to implement, and starvation-free. Round-robin scheduling can also be applied to other scheduling problems, such as data packet scheduling in computer networks. It is anOperating System concept. The name of the algorithm comes from the round-robin principle known from other fields, where each person takes an equal share of something in turn. Direction: Round RobinAlgorithm in C++ #include using namespace std; int main() { int bt[20],p[20],wt[20],tat[20],pr[20],i,j,n,total=0,pos,temp,avg_wt,avg_tat; cout<<"Enter Total Number of Process:"; cin>>n; cout<<"nEnter Burst Time and Priorityn"; for(i=0;i >bt

Lab No 6 First Come First Serve (FCFS) Algorithm

Image
Perhaps, First-Come-First-Served algorithm is the simplest scheduling algorithm. Processes are dispatched according to their arrival time on the ready queue. Being a non-preemptive discipline, once a process has a CPU, it runs to completion. The FCFS scheduling is fair in the formal sense or human sense of fairness but it is unfair in the sense that long jobs make short jobs wait and unimportant jobs make important jobs wait. FCFS is more predictable than most of other schemes since it offers time. FCFS scheme is not useful in scheduling interactive users because it cannot guarantee good response time. The code for FCFS scheduling is simple to write and understand. One of the major drawback of this scheme is that the average time is often quite long. The First-Come-First-Served algorithm is rarely used as a master scheme in modern operating systems but it is often embedded within other schemes. Direction: FCFS(first come first serve) in C++. #include using namespace std; int main()

Lab No 5 Ubuntu Basic Programing Syntax Variables

Image
Variables basically store information. You set variables like this using text editor: var="FOO" 'var' can be anything you want as long as it doesn't begin with a number. "FOO" can be anything you want. To access the information from the variable you need to put a '$' in front of it like this: var="FOO" echo $var Try entering those lines into a terminal one at a time; you will see that the first one just gives you another prompt and the second one print FOO. But that's all a bit boring. So let's make a script to ask the user for some information and then echo that information. #!/bin/bash clear echo "Please enter your name" read name echo "Please enter your age" read age echo "Please enter yourgender. Male/Female" read gender echo "So you're a $age year old $gender called $name" read allows the user to input information where it is then stored in the variable defined after the read.

Lab No 4 Running commands as root

Image
When working on the command line, you usually want to work with the default permissions. This way you insure that you won't accidentally break anything belonging to the system or other users, so long as the system and other users haven't altered their file permissions. Yet there will be times when you wish to copy a file to a system folder (like /usr/local/bin) to make it available to all users of the system. Only the system administrator (i.e. the user 'root') should have permission to alter the contents of system directories like /usr/local/bin. Therefore trying to copy a file (like a program downloaded from the Internet) into that folder is forbidden by default. cp Downloads/some_downloaded_program /usr/local/bin cp: cannot create regular file `/usr/local/bin/some_downloaded_program': Permission denied Since it would be very tedious to always login as root to do administrative work (in fact you should avoid logging in as root with a graphical desktop) you can u

Lab No 3 Manage Processes from the Linux Terminal

Image
The Linux terminal has a number of useful commands that can display running processes, kill them, and change their priority level. This post lists the classic, traditional commands, as well as some more useful, modern ones. Many of the commands here perform a single function and can be combined — that’s the Unix philosophy of designing programs. Other programs, like htop, provide a friendly interface on top of the commands. Top The top command is the traditional way to view your system’s resource usage and see the processes that are taking up the most system resources. Top displays a list of processes, with the ones using the most CPU at the top. To exit top or htop, use the Ctrl-C keyboard shortcut. This keyboard shortcut usually kills the currently running process in the terminal. htop The htop command is an improved top. It’s not installed by default on most Linux distributions — here’s the command you’ll need to install it on Ubuntu: sudo apt-get install htop htop display