OS & DBMS Lab


Lab Manual
 Web View
Download


Exercises:

 S.No. Name of the Expirement
 Date Time Status Remarks
 1First Come First Served scheduling algorithm
 26.8.2010 - Completed 
 2The critical-section problem
 26.8.2010 - Completed 
 3Banker's Algorithm
 26.8.2010 - Completed 
 4The Dining Philosopher's Problem
 26.8.2010 - Completed 
 5Creation of tables
 26.8.2010 - Completed 
 6Report Generation
 26.8.2010 - Completed 
 7A PL/SQL program involving simple SQL Queries 26.8.2010 - Completed 
 8A PL/SQL program using aggregate functions
 26.8.2010 - Completed 
 9Cursor Management
 26.8.2010 - Completed 
 10Library Management System
 26.8.2010 - Completed 



1. Implement the FCFS Problem using C language constructs.

Solution:

FCFS - Demo

#include<stdio.h>
#include<conio.h>
main()
{
    int n,i,j,sum=0;
    int arrival[10],service[10],start[10];
    int finish[10],wait[10],turn[10];
    float avgturn=0.0,avgwait=0.0;
    start[0]=0;
    clrscr();
    printf("Enter the number of processes:");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        printf("Enter the arrival and service time of %d process:",i+1);
        scanf("%d%d",&arrival[i],&service[i]);
    }
    for(i=0;i<n;i++)
    {
        sum=0;
        for(j=0;j<i;j++)
        sum=sum+service[j];
        start[i]=sum;
    }
    for(i=0;i<n;i++)
    {
        finish[i]=service[i]+start[i];
        wait[i]=start[i];
        turn[i]=service[i]+wait[i];
    }
    for(i=0;i<n;i++)
    {
        avgwait+=wait[i];
        avgturn+=turn[i];
    }
    avgwait/=n;
    avgturn/=n;
    printf("\nArrival Service Start Finish Wait Turn\n");
    for(i=0;i<n;i++)
    printf("%d\t%d\t%d\t%d\t%d\t%d\n",arrival[i],service[i],start[i],
finish[i],wait[i],turn[i]);
    printf("\nAverage waiting time=%f",avgwait);
    printf("\nAverage turn around time=%f",avgturn);
    getch();
}


Screenshot:


2. Implement the Critical Section problem using C language as per the algorithm given.
Screenshot:


3. Implement Banker's algorithm using C Language as per the algorithm given.
Screenshot:

4. Implement the Dining Philosopher's problem using C Language as per the algorithm given.
Screenshot:


5. Given the following relations:

Emp Table (Emp#, Empname, City, Acc#)
Acc Table (Acc#, OpenDate, Bal-Amt)

Write corresponding create table statements, insert data into the relations and show the output.

Solution

CREATE TABLE Emp(Emp# INT, Empname varchar(120), City varchar(60), Acc# INT PRIMARY KEY)

CREATE TABLE Acc(Acc# INT FOREIGN KEY REFERENCES Emp(Acc#), Opendate datetime, Bal_Amt float, PRIMARY KEY (Acc#))

INSERT INTO Emp VALUES(1200, 'Name1', 'Area1', 33225)

INSERT INTO Acc VALUES(33225, '08/28/2010', 25652.56)

SELECT Emp.Emp#, Emp.Empname, Emp.City, Acc.Acc#, Acc.Opendate, Acc.Bal_Amt FROM Emp JOIN Acc ON Emp.Acc#=Acc.Acc#




6. Generate the yearly report (from first January of an year to 31st December of the same year) on the total amounts of individual accounts of each employee in the following format:

Emp Table (Emp#, Empname, City, Acc#)
Acc Table (Acc#, OpenDate, Bal-Amt)

Yearly Report
Emp#       Empname      Acc#      Bal-Amt


7. Write PL/SQL program to create a Employee table with the fields EmpNo, Empname, Designation, Salary and Dateofjoin. Insert 10 records and display the records of only those employee whose salary is more than 15,000.

8. Write a PL / SQL program to calculate the total, average and grade of given student.

9. Write a PL / SQL program to calculate the total, average and grade of students using cursors.

10. Design and implement library management system in RDBMS.