Posts

Showing posts from September, 2020

Physical machine Extended machine Processor(s) Threads Memory Processes

Operating Systems Peter Druschel and Rodrigo Rodrigues MPI-SWS and Saarland University 1 Introduction Required readings: Silberschatz/Galvin: Chapters 1-3 What is an operating system? Layer of software between the hardware and application programs. Two main functions: • Resource manager • Extended (abstract) machine OS as resource manager • mediator/coordinator: resolve conflicting resource demands • protect users from each others (and from themselves) • mechanisms and policies for control of resources, flow of information OS as extended machine • provides stable, portable, reliable, safe, well-behaved environment (ideally) • Magician: makes computer appear to be more than it really is • Single processor appears like many separate processors • Single memory made to look like many separate memories, each potentially larger than the real memory 1 Operating Systems 2 Physical machine Extended machine Processor(s) Threads Memory Processes Disks Files Network adaptors Operating Comm. channe

Lab. No. 14 Page Replacement Direction:Paging ReplacementAlgorithm in C++.

Lab. No. 14 Page Replacement Direction:Paging ReplacementAlgorithm in C++. #include using namespace std; #include int main() { intnop,nof,page[20],i,count=0; cout<<"\n\tEnter the No. of Pages:"; cin>>nop; cout<<"\n\t Enter the Reference String:"; for(i=0;i >page[i];} cout<<"\n\t Enter the No of frames:-"; cin>>nof; int frame[nof],fcount[nof]; for(i=0;i "; if(flag==0) { if(i>=nof) { int max=0,k=0; while(k<nof) { intdist=0,j1=i+1; while(j1<nop) { if(frame[k]!=page[j1]) dist++; else{ break; } j1++; } fcount[k]=dist; k++; } k=0; while(k<nof-1) { if(fcount[max]<fcount[k+1]) max=k+1; k++; } frame[max]=page[i]; } else { frame[i%nof]=page[i]; } count++; while(j<nof) { cout<<"\t|"<<frame[j]<<"|"; j++; } } i++; } cout<<"\n\t**************************************\n"; cout<<"\n\tPage Fault is:"<<count; getch(); return

Lab. No 13 Highest Response Ratio Direction:Paging Algorithm in C.

Lab. No 13 Highest Response Ratio Direction:Paging Algorithm in C. #include int main() { inti,j,n,a[50],frame[10],no,k,avail,count=0; printf("\n ENTER THE NUMBER OF PAGES:\n"); scanf("%d",&n); printf("\n ENTER THE PAGE NUMBER :\n"); 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); return 0; } Output: Comments: ___________________________. Date: ______________________. Signature of Lab Instructor: _____________________.

Lab. No 12 Feed Back Scheme Direction: Feedback scheme.

Lab. No 12 Feed Back Scheme Direction: Feedback scheme. #include #include usingnamespace std; structprocess { int pid; int atime; int btime; int rtime; int priority; int stime; int etime; }; structmycomp { booloperator()(constprocess& lhs, constprocess& rhs) const { return lhs.priority > rhs.priority; } }; void printproc(process arr[],int n) { printf("\nPROCESS TABLE"); for(int i=0;i , mycomp> q1; queue q2; int time=0,turn; turn = 0; int quanta=4,rquanta=4; int flag1=0; while((!q1.empty())||(!q2.empty())||(flag1==0)||(turn 0) q2.push(q1.top()); q1.pop(); quanta=4; } } elseif(!q2.empty()) { q2.front().rtime = q2.front().rtime-1; printf("\nIn RR rtime for %d is : %d",q2.front().pid,q2.front().rtime); chart[time]=q2.front().pid; rquanta--; if(q2.front().rtime==0) { q2.pop(); rquanta=4; } elseif(rquanta==0) { printf("\trquanta is zero, removing and adding at end %d",q2.front().pid); q2.push(q2.front()); q2.pop(); rquanta=4; } } printf("

Lab. No 11 Pure Priority Scheme OS

Lab. No 11 Pure Priority Scheme Direction: 2nd Chance Page Replacement. #include #define SIZE 3 int full=0;//To check whether all frames are filled int a[21];//To take the input intref[SIZE];//This is for reference bits for each frame int frame[SIZE]; int repptr=0;//Initialised to first frame int count=0; int display() { int i; printf("\nThe elements in the frame are\n"); for(i=0;i<full;i++) printf("%d\n",frame[i]); } int Pagerep(int ele) { int temp; /*Whenever a page needs to be replaced the repptr moves from page to page checking whether it's reference bit is 0 or not, if it is 0 itcoomes out of the while loop and if it is one, it gives a second chance setting the reference bit to 0*/ while(ref[repptr]!=0) { ref[repptr++]=0; if(repptr==SIZE) repptr=0; } temp=frame[repptr]; frame[repptr]=ele; ref[repptr]=1;//The latest page reference, hence it is set to 1 return temp; } int Pagefault(int ele) { if(full!=SIZE) { ref[full]=1;//All t

Lab 10 Memory Management in Paging Scheme On OS

Lab 10 Memory Management in Paging Scheme In computer operating systems, paging is a memory management scheme by which a computer stores and retrieves data from secondary storage[a] for use in main memory. In this scheme, the operating system retrieves data from secondary storage in same-size blocks called pages. Paging is an important part of virtual memory implementations in modern operating systems, using secondary storage to let programs exceed the size of available physical memory. For simplicity, main memory is called "RAM" (abbreviated from "random-access memory") and secondary storage is called "disk" (a shorthand for "hard disk drive"), but the concepts do not depend on whether these terms apply literally to a specific computer system. Direction: Memory Management in Paging Scheme in C. #include #include int main() { int st[10], bt[10], wt[10], tat[10], n, tq; int i, count=0, swt=0, stat=0, temp, sq=0; float awt=0.0, atat=0.0; printf

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

Boot Windows Oops, we get this horrible error! new method

Image
Whenever you use a partitioning tool against an installed system, there's a chance of a problem, filesystem corruption and who knows what else. There is no guarantee for success. Re-partitioning of installed operating systems is risky. This is why you should always create your setup BEFORE installations, so you never have to face this kind of problem. Repair unbootable Windows installation Following the instructions, we will boot from the Windows installation disc. Click on Repair your computer: And you will see this menu: Let Windows repair itself. It should do a pretty good job. Indeed, we're up and running. Windows 7 will start booting and recommend you run check disk against your disk, offering yet another hint that the resizing procedure messed things up a little. You should indeed let the tool run. And soon, you'll see the login menu: And here we can see the changes in My Computer and the Disk Management. One thing that Windows 7 does not report corr

Lab No 2 Installing Windows 7 and Ubuntu side by side

Image
To install Ubuntu on a computer that already has Windows 7 installed. We will have to accommodate space for our Ubuntu installation. To this end, we will use the GParted partitioning tool to resize (shrink) the Windows installation and create new partitions for Ubuntu. After Ubuntu is installed, we will have to deal with an error - a typical case of unbootable Windows, a common problem that can occur when the Windows installation is changed. We will learn how to deal with this problem simply and efficiently using the built-in tools, fixing the Windows boot issue. Data loss Whenever you're about to change the existing installation, there's a risk of data loss, regardless of which operating system you're about to install. It is important to make sure you have your critical data backed up to external media. You should also verify that your backups are intact and that they can be restored. Boot into Ubuntu live CD session Very fortunately, Ubuntu (as many other Linux distro

Lab No 1 Introduction to Ubuntu Manual.

Lab No 1 Introduction to Ubuntu Ubuntu: Ubuntu is an ancient African word meaning ‘humanity to others’. It also means ‘I am what I am because of who we all are’. The Ubuntu operating system brings the spirit of Ubuntu to the world of computers. Linux was already established as an enterprise server platform in 2004, but free software was not a part of everyday life for most computer users. That’s why Mark Shuttle worth gathered a small team of developers from one of the most established Linux projects — Debi an — and set out to create an easy-to-use Linux desktop: Ubuntu. The vision for Ubuntu is part social and part economic: free software, available to everybody on the same terms, and funded through a portfolio of services provided by Canonical. Ubuntu today has nine flavors and dozens of localized and specialized derivatives. There are also special editions for servers, Open Stack clouds, and mobile devices. All editions share common infrastructure and software, making Ubuntu a uniqu

Robin Round Operating System Assignment No 2

Image
Q1: In 2013, which of these theories was adjusted to account for advances in technological development: Moore's law, Butter's law, Kryder's law, or the theory of planned behavior? Moore’s Law? Coined in 1965 by Intel co-founder Gordon Moore, Moore’s Law predicted the doubling of transistors per chip every two years. Originally based on only five data points, Moore’s Law turned out to be an astonishingly accurate prediction, recently celebrating its 50th anniversary to much media acclaim. It’s served as an iron rule of innovation and a figurehead for the accelerating speed of progress. With the global economy increasingly dominated by things with transistor chips inside them, the implications of Moore’s Law have been profound. However, we’ve been seeing signs for some time now that our assumptions about Moore’s Law can’t be taken for granted. As journalists like John Markoff from the New York Times have pointed out, technology companies are finding it increasingly difficul

Operating System Final Term Previous Paper

Image
Universt XYZ Final-Term Examination-Spring 2018 Course Code: CS-313 Course Title: Operating System Concept Teacher’s Name: XYZ Total Marks: 50 Date And Time: Total Time: 2 Hours Student’s Name: Reg. No.: ---------------------------------------------------------------------------------------------------------------------------------------------- Students are advised to read and follow these instructions: 1. Write your Registration Number, other relevant information on the front page of the answer booklet sign it in the appropriate space. 2. Point out any discrepancy (torn pages, loose sheets etc.) to the invigilating staff. 3. Do not share/borrow stationery items and calculator. 4. Manage your time according to the marks allotted to the respective questions. 5. Please ensure that the area in your threshold is clean. You will be charged for any material which can be classified as ‘helping in the paper’ found near you. 6. Ask for clarifications by the Course Instructor only with