MCC Workshop Booklet
MCC Workshop Booklet
MCC Workshop Booklet
1. Demonstrateroundrobin/priorityschedulingusingthreads.
RoundRobin
importjava.io.*;
classjobimplementsRunnable
{
intprocess_id,no_of_instr,time_quantum;
Threadt;
job(intpid,intinstr,inttq)
{
process_id=pid;
no_of_instr=instr;
time_quantum=tq;
t=newThread(this);
t.start();
}
publicvoidrun()
{
try
{
for(inti=1;i<=no_of_instr;i++)
{
System.out.println("Executinginstrno"+i+"ofprocess"+process_id);
Thread.sleep(time_quantum);
}
System.out.println("Job"+process_id+"isover");
}
catch(InterruptedExceptione)
{
System.out.println("Thejobhasbeeninterrupted...");
}
}
}
classos
{
publicstaticvoidmain(Stringargs[])
{
try
{
intprocess_id=100,time_quantum=100;
BufferedReaderbr=newBufferedReader(newInputStreamReader(System.in));
System.out.println("Enterauserprocessstartingnumber:");
process_id=Integer.parseInt(br.readLine());
System.out.println("Enteratimequantum(inmillis):");
time_quantum=Integer.parseInt(br.readLine());
jobj1=newjob(++process_id,10,time_quantum);
jobj2=newjob(++process_id,6,time_quantum);
jobj3=newjob(++process_id,8,time_quantum);
}
catch(Exceptione)
{
System.out.println("Someprocessfailedtocomplete...");
System.out.println("Plzcontactsystemadmin...");
}
}
}
Output
Enterauserprocessstartingnumber:
500
Enteratimequantum(inmillis):
100
Executinginstrno1ofprocess501
Executinginstrno1ofprocess502
Executinginstrno1ofprocess503
Executinginstrno2ofprocess502
Executinginstrno2ofprocess501
Executinginstrno2ofprocess503
Executinginstrno3ofprocess502
Executinginstrno3ofprocess501
Executinginstrno3ofprocess503
Executinginstrno4ofprocess502
Executinginstrno4ofprocess501
Executinginstrno4ofprocess503
Executinginstrno5ofprocess502
Executinginstrno5ofprocess501
Executinginstrno5ofprocess503
Executinginstrno6ofprocess502
Executinginstrno6ofprocess501
Executinginstrno6ofprocess503
Job502isover
Executinginstrno7ofprocess501
Executinginstrno7ofprocess503
Executinginstrno8ofprocess501
Executinginstrno8ofprocess503
Executinginstrno9ofprocess501
Job503isover
Executinginstrno10ofprocess501
Job501isover
Priority
importjava.io.*;
classjobimplementsRunnable
{
intprocess_id,no_of_instr,priority_value,time_quantum;
Threadt;
job(intpid,intinstr,intprio,inttq)
{
process_id=pid;
no_of_instr=instr;
time_quantum=tq;
priority_value=prio;
t=newThread(this);
t.setPriority(priority_value);
t.start();
}
publicvoidrun()
{
try
{
for(inti=1;i<=no_of_instr;i++)
{
System.out.println("Executinginstrno"+i+"ofprocess"+process_id);
Thread.sleep(time_quantum);
}
System.out.println("Job"+process_id+"isover");
}
catch(InterruptedExceptione)
{
System.out.println("Thejobhasbeeninterrupted...");
}
}
}
classos
{
publicstaticvoidmain(Stringargs[])
{
try
{
intprocess_id=100,time_quantum=100;
BufferedReaderbr=newBufferedReader(newInputStreamReader(System.in));
System.out.println("Enterauserprocessstartingnumber:");
process_id=Integer.parseInt(br.readLine());
System.out.println("Enteratimequantum(inmillis):");
time_quantum=Integer.parseInt(br.readLine());
jobj1=newjob(++process_id,8,9,time_quantum);
jobj2=newjob(++process_id,8,1,time_quantum);
jobj3=newjob(++process_id,8,2,time_quantum);
}
catch(Exceptione)
{
System.out.println("Someprocessfailedtocomplete...");
System.out.println("Plzcontactsystemadmin...");
}
}
}
Output
Enterauserprocessstartingnumber:
500
Enteratimequantum(inmillis):
100
Executinginstrno1ofprocess502
Executinginstrno1ofprocess501
Executinginstrno1ofprocess503
Executinginstrno2ofprocess502
Executinginstrno2ofprocess503
Executinginstrno2ofprocess501
Executinginstrno3ofprocess501
Executinginstrno3ofprocess503
Executinginstrno3ofprocess502
Executinginstrno4ofprocess503
Executinginstrno4ofprocess502
Executinginstrno4ofprocess501
Executinginstrno5ofprocess502
Executinginstrno5ofprocess503
Executinginstrno5ofprocess501
Executinginstrno6ofprocess501
Executinginstrno6ofprocess503
Executinginstrno6ofprocess502
Executinginstrno7ofprocess503
Executinginstrno7ofprocess502
Executinginstrno7ofprocess501
Executinginstrno8ofprocess501
Executinginstrno8ofprocess503
Executinginstrno8ofprocess502
Job503isover
Job502isover
Job501isover
2. Foranyschedulingalgorithm,calculateturnaroundtime.
importjava.io.*;
importjava.util.*;
//classjobrepresentsosprocess
//eachjobhassomenumberofinstructions
//OSassignsprocessidandtimequantum
classjobimplementsRunnable
{
intprocess_id,no_of_instr,time_quantum;
longmillis;
Threadt;
job(intpid,intinstr,inttq)
{
millis=System.currentTimeMillis();
process_id=pid;
no_of_instr=instr;
time_quantum=tq;
t=newThread(this);
t.start();
}
publicvoidrun()
{
try
{
for(inti=1;i<=no_of_instr;i++)
{
//System.out.println("Executinginstrno"+i+"ofprocess"+process_id);
Thread.sleep(time_quantum);
}
millis=System.currentTimeMillis()millis;
os.millitime=os.millitime+millis;
System.out.println("Job"+process_id+"with"+no_of_instr+"instructionshascompletedin"+
millis+"milliseconds");
}
catch(InterruptedExceptione)
{
System.out.println("Thejobhasbeeninterrupted...");
}
}
}
classos
{
staticlongmillitime=0;
staticintprocess_id=100,time_quantum=100;
publicstaticvoidmain(Stringargs[])
{
try
{
BufferedReaderbr=newBufferedReader(newInputStreamReader(System.in));
System.out.println("Enterauserprocessstartingnumber:");
process_id=Integer.parseInt(br.readLine());
System.out.println("Enteratimequantum(inmillis):");
time_quantum=Integer.parseInt(br.readLine());
jobj1=newjob(++process_id,25,time_quantum);
jobj2=newjob(++process_id,15,time_quantum);
jobj3=newjob(++process_id,9,time_quantum);
Threadmainthread=Thread.currentThread();
mainthread.sleep(3000);
System.out.println("Averageturnaroundtime="+(millitime)/3.0f);
}
catch(Exceptione)
{
System.out.println("Someprocessfailedtocomplete...");
System.out.println("Plzcontactsystemadmin...");
}
}
}
Output
Enterauserprocessstartingnumber:
500
Enteratimequantum(inmillis):
100
Job503with9instructionshascompletedin922milliseconds
Job502with15instructionshascompletedin1531milliseconds
Job501with25instructionshascompletedin2547milliseconds
Averageturnaroundtime=1666.6666
3. Demonstratetheconceptofsynchronizedaccesstosharedresource
classroom
{
publicsynchronizedvoidtakesLecture(Stringname)throwsInterruptedException
{
System.out.println(name+"enters...");
Thread.sleep(250);
System.out.println(name+"startslecture...");
Thread.sleep(500);
System.out.println(name+"exits...");
Thread.sleep(250);
}
}
classlecturerimplementsRunnable
{
Stringname;
roomr;
Threadt;
lecturer(Stringn,roomr)
{
name=n;
t=newThread(this,n);
this.r=r;
}
publicvoidstart()
{
t.start();
}
publicvoidrun()
{
try
{
r.takesLecture(name);
}
catch(InterruptedExceptione)
{
System.out.println(name+"operationinterrupted...");
}
}
}
classos
{
publicstaticvoidmain(Stringargs[])
{
roomr=newroom();
lecturerkamlakar=newlecturer("KamlakarSir",r);
lecturermadhavi=newlecturer("MadhaviMadam",r);
lecturerprajisha=newlecturer("PrajishaMadam",r);
kamlakar.start();
madhavi.start();
prajisha.start();
}
}
Output
KamlakarSirenters...
KamlakarSirstartslecture...
KamlakarSirexits...
PrajishaMadamenters...
PrajishaMadamstartslecture...
PrajishaMadamexits...
MadhaviMadamenters...
MadhaviMadamstartslecture...
MadhaviMadamexits...
4. Demonstratetheuseofinterprocesscommunication
ProducerConsumerproblemFromJ2CR
DiningPhilosopherproblemtobesolved
5. Demonstrateany1ofdeadlockavoidancealgorithm
importjava.io.*;
classBanker
{
intavail[];
intmax[][]={{3,2,2,1},{8,12,0,0},{2,1,0,0},{4,3,0,0},{2,0,3,1}};
intalloc[][]={{1,1,1,0},{2,1,0,0},{1,0,0,0},{2,1,0,0},{1,0,0,0}};
intneed[][];
intm,n;
Banker()
{
m=4;
n=5;
avail=newint[4];
avail[0]=16;//NumberofRegisters
avail[1]=50;//NumberofFiles
avail[2]=5;//NumberofPorts
avail[3]=2;//NumberofPrinter
need=newint[5][4];
for(inti=0;i<5;i++)
for(intj=0;j<4;j++)
need[i][j]=max[i][j]alloc[i][j];
}
booleanisSafe()
{
intwork[]=newint[m];
booleanfinish[]=newboolean[n];
for(inti=0;i<m;i++)
work[i]=avail[i];
for(inti=0;i<n;i++)
finish[i]=false;
for(inti=0;i<n;i++)
{
if(finish[i]==false)
{
booleanincomplete=false;
for(intj=0;j<m;j++)
{
if(need[i][j]>work[j])
{
incomplete=true;
//System.out.println(i+":"+j+":"+need[i][j]+":"+work[j]);
}
if(need[i][j]!=0&&need[i][j]<=work[j])
{
work[j]=work[j]need[i][j];
}
}
if(!incomplete)
{
finish[i]=true;
}
if(finish[i])
System.out.println("Process"+i+"canbecompleted");
else
System.out.println("Process"+i+"can'tbecompleted");
}
}
for(inti=0;i<n;i++)
{
if(!finish[i])
{
returnfalse;
}
}
returntrue;
}
voidresourceRequest()
{
intrequest[][]={{1,1,1,0},{2,2,0,0},{1,1,0,1},{1,1,0,0},{1,0,0,0}};
booleansafe=true;
for(inti=0;i<n;i++)
{
for(intj=0;j<m;j++)
{
if(request[i][j]<=need[i][j])
{
if(request[i][j]<=avail[j])
{
avail[j]=avail[j]request[i][j];
alloc[i][j]=alloc[i][j]+request[i][j];
need[i][j]=need[i][j]request[i][j];
}
else
{
System.out.println("Heyprocess"+i+"!resource"+j+"isnotavailablenow...tryagain
later...");
}
}
else
{
System.out.println("Process"+i+"hasexceededrequestforresource"+j+"henceis
unsafe");
safe=false;
}
}
}
if(safe)
{
System.out.println("thesystemissafe...");
}
else
{
System.out.println("thesystemisunsafe...");
}
}
}
classos
{
publicstaticvoidmain(Stringargs[])throwsException
{
Bankerb=newBanker();
System.out.println("Applyingsafetyalgorithm...");
if(b.isSafe())
{
System.out.println("Thesystemisinsafestate...");
}
else
{
System.out.println("Thesystemisnotinsafestate....");
}
System.out.println("Applyingresourcerequestalgo...");
b.resourceRequest();
}
}
Ouput
Applyingsafetyalgorithm...
Process0canbecompleted
Process1canbecompleted
Process2canbecompleted
Process3canbecompleted
Process4canbecompleted
Thesystemisinsafestate...
Applyingresourcerequestalgo...
Process2hasexceededrequestforresource3henceisunsafe
thesystemisunsafe...
6. Demonstratememorymanagementusingfirst/best/worstfit
importjava.util.*;
importjava.io.*;
classJob
{
intinstr[];
intprocess_id,size;
Job(intpid,intn)
{
process_id=pid;
size=n;
instr=newint[size];
for(inti=0;i<size;i++)
{
instr[i]=process_id+i+1;
}
}
intgetSize()
{
returnsize;
}
int[]getInstr()
{
returninstr;
}
intgetProcessId()
{
returnprocess_id;
}
}
classMemMgmt
{
intmemory_array[];
Vectorjobqueue;
MemMgmt(Vectorv)
{
jobqueue=v;
memory_array=newint[20];
for(inti=0;i<20;i++)
{
memory_array[i]=0;
}
System.out.println("Initialmemorylayout...");
printArray();
}
voidaddJob(Jobnewjob)
{
jobqueue.add(newjob);
}
voidaddSortedJob(Jobnewjob)
{
if(jobqueue.size()==0)
{
jobqueue.add(newjob);
return;
}
for(inti=0;i<jobqueue.size();i++)
{
Jobj=(Job)jobqueue.elementAt(i);
if(j.getSize()>=newjob.getSize())
{
jobqueue.insertElementAt(newjob,i);
return;
}
}
jobqueue.add(newjob);
}
voidprintArray()
{
System.out.println();
System.out.print("|");
for(inti=0;i<20;i++)
{
System.out.print(memory_array[i]+"|");
}
}
voidfirstFit()
{
intmem_arr_index=0;
for(inti=0;i<jobqueue.size();i++)
{
Jobjob=(Job)jobqueue.elementAt(i);
intinstr_array[]=job.getInstr();
if(20mem_arr_index>=instr_array.length)
{
System.out.print("\n\ncopying"+instr_array.length+"instructionsatlocation"+
mem_arr_index);
for(intj=0;j<instr_array.length;j++)
{
memory_array[mem_arr_index]=instr_array[j];
mem_arr_index++;
}
printArray();
}
else
{
System.out.println("\nJobwithprocessid"+job.getProcessId()+"istoobig!");
}
}
}
voidworstFit()
{
intmem_arr_index=0;
for(inti=jobqueue.size()1;i>=0;i)
{
Jobjob=(Job)jobqueue.elementAt(i);
intinstr_array[]=job.getInstr();
if(20mem_arr_index>=instr_array.length)
{
System.out.print("\n\ncopying"+instr_array.length+"instructionsatlocation"+
mem_arr_index);
for(intj=0;j<instr_array.length;j++)
{
memory_array[mem_arr_index]=instr_array[j];
mem_arr_index++;
}
printArray();
}
else
{
System.out.println("\nJobwithprocessid"+job.getProcessId()+"istoobig!");
}
}
}
}
classos
{
publicstaticvoidmain(Stringargs[])throwsException
{
Vectorv=newVector();
MemMgmtm=newMemMgmt(v);
Jobjob1=newJob(500,9);
Jobjob2=newJob(200,2);
Jobjob3=newJob(900,6);
System.out.println("\n\nEnterpolicy:\n1:FirstFit\n2:BestFit\n3:WorstFit");
BufferedReaderbr=newBufferedReader(newInputStreamReader(System.in));
intpolicy=Integer.parseInt(br.readLine());
if(policy==1)
{
System.out.println("\nApplyingFirstFitPolicy...");
m.addJob(job1);
m.addJob(job2);
m.addJob(job3);
m.firstFit();
}
else
if(policy==2)
{
System.out.println("\nApplyingBestFitPolicy...");
m.addSortedJob(job1);
m.addSortedJob(job2);
m.addSortedJob(job3);
m.bestFit();
}
else
if(policy==3)
{
System.out.println("\nApplyingWorstFitPolicy...");
m.addSortedJob(job1);
m.addSortedJob(job2);
m.addSortedJob(job3);
m.worstFit();
}
}
}
Output
Initialmemorylayout...
|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|
Enterpolicy:
1:FirstFit
2:BestFit
3:WorstFit
ApplyingBestFitPolicy...
copying2instructionsatlocation0
|201|202|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|
copying6instructionsatlocation2
|201|202|901|902|903|904|905|906|0|0|0|0|0|0|0|0|0|0|0|0|
copying9instructionsatlocation8
|201|202|901|902|903|904|905|906|501|502|503|504|505|506|507|508|509|0|0|0|
7. Demonstratepagereplacementalgorithm
importjava.io.*;
classMemMgmt
{
Stringframe_sequence;
intmem_block[];
MemMgmt(Stringfs,intn)
{
frame_sequence=fs;
mem_block=newint[n];
for(inti=0;i<n;i++)
mem_block[i]=1;
}
voiddispMemBlock()
{
System.out.print("|");
for(inti=0;i<mem_block.length;i++)
{
System.out.print(mem_block[i]+"|");
}
System.out.println();
}
voidfcfs()
{
System.out.println("=======FCFS===========");
Stringstrpages[]=frame_sequence.split("");
intpages[]=newint[strpages.length];
for(inti=0;i<strpages.length;i++)
pages[i]=Integer.parseInt(strpages[i]);
intmem_block_num=0,page_faults=0;
System.out.println("InitialMemorylayout...");
dispMemBlock();
for(inti=0;i<pages.length;i++)
{
booleanpresent=false;
for(intj=0;j<mem_block.length;j++)
{
if(mem_block[j]==pages[i])
{
present=true;
break;
}
}
if(!present)
{
mem_block[mem_block_num]=pages[i];
mem_block_num++;
page_faults++;
}
if(mem_block_num==mem_block.length)
mem_block_num=0;
System.out.println("Loadingpageno."+(i+1)+":"+pages[i]);
dispMemBlock();
}
System.out.println("TotalNumberofpagefaults:"+page_faults);
}
voidoppr()
{
System.out.println("=======OptimalPageReplacement===========");
Stringstrpages[]=frame_sequence.split("");
intpages[]=newint[strpages.length];
inti=0;
for(i=0;i<strpages.length;i++)
pages[i]=Integer.parseInt(strpages[i]);
intmem_block_num=0,page_faults=0;
System.out.println("InitialMemorylayout...");
dispMemBlock();
for(i=0;i<mem_block.length;i++)
{
booleanpresent=false;
for(intj=0;j<mem_block.length;j++)
{
if(mem_block[j]==pages[i])
{
present=true;
break;
}
}
if(!present)
{
mem_block[mem_block_num]=pages[i];
mem_block_num++;
page_faults++;
}
System.out.println("Loadingpageno."+(i+1)+":"+pages[i]);
dispMemBlock();
}
for(;i<pages.length;i++)
{
booleanpresent=false;
for(intj=0;j<mem_block.length;j++)
{
if(mem_block[j]==pages[i])
{
present=true;
break;
}
}
if(!present)
{
mem_block_num=1;
intlongest_page=1;
for(intj=0;j<mem_block.length;j++)
{
intk=0;
for(k=i+1;k<pages.length;k++)
{
if(mem_block[j]==pages[k])
{
if(k>longest_page)
{
longest_page=k;
mem_block_num=j;
}
break;
}
}
if(k==pages.length)
{
longest_page=pages.length;
mem_block_num=j;
}
}
mem_block[mem_block_num]=pages[i];
page_faults++;
}
System.out.println("Loadingpageno."+(i+1)+":"+pages[i]);
dispMemBlock();
}
System.out.println("TotalNumberofpagefaults:"+page_faults);
}
}
classos
{
publicstaticvoidmain(Stringargs[])throwsException
{
BufferedReaderbr=newBufferedReader(newInputStreamReader(System.in));
System.out.println("Enterpageframesequence(separatedbyspace):");
//Stringframe_sequence=br.readLine();
Stringframe_sequence="70120304230321201701";
System.out.println("Enterpagereplacementalgo:");
inti=Integer.parseInt(br.readLine());
MemMgmtm=newMemMgmt(frame_sequence,3);
if(i==1)
m.fcfs();
else
if(i==2)
m.oppr();
}
}
Output
Enterpageframesequence(separatedbyspace):
Enterpagereplacementalgo:
=======OptimalPageReplacement===========
InitialMemorylayout...
|1|1|1|
Loadingpageno.1:7
|7|1|1|
Loadingpageno.2:0
|7|0|1|
Loadingpageno.3:1
|7|0|1|
Loadingpageno.4:2
|2|0|1|
Loadingpageno.5:0
|2|0|1|
Loadingpageno.6:3
|2|0|3|
Loadingpageno.7:0
|2|0|3|
Loadingpageno.8:4
|2|4|3|
Loadingpageno.9:2
|2|4|3|
Loadingpageno.10:3
|2|4|3|
Loadingpageno.11:0
|2|0|3|
Loadingpageno.12:3
|2|0|3|
Loadingpageno.13:2
|2|0|3|
Loadingpageno.14:1
|2|0|1|
Loadingpageno.15:2
|2|0|1|
Loadingpageno.16:0
|2|0|1|
Loadingpageno.17:1
|2|0|1|
Loadingpageno.18:7
|7|0|1|
Loadingpageno.19:0
|7|0|1|
Loadingpageno.20:1
|7|0|1|
TotalNumberofpagefaults:9
8. Demonstratediskschedulingalgorithm
importjava.io.*;
classDevMgmt
{
Stringdisk_sequence;
DevMgmt(Stringfs)
{
disk_sequence=fs;
}
voidsstf(intstart_track)
{
System.out.println("=======SHORTESTSEEKTIMEFIRST===========");
Stringdisknums[]=disk_sequence.split("");
inttracks[]=newint[disknums.length];
booleantracks_bool[]=newboolean[disknums.length];
intmin_dist=0,max_dist=0;
for(inti=0;i<disknums.length;i++)
{
tracks[i]=Integer.parseInt(disknums[i]);
tracks_bool[i]=false;
max_dist=max_dist+tracks[i];
}
min_dist=max_dist;
for(inti=0;i<disknums.length;i++)
{
//System.out.println(tracks[i]+":"+tracks_bool[i]);
}
//System.out.println(min_dist);
inttotal_cylinders=0,from_track=start_track,current_track_index=1;
System.out.println("Traversingfrom:"+from_track);
for(inti=0;i<tracks.length;i++)
{
//System.out.println("i="+i+",from_track:"+from_track);
intto_track_index=0;
for(intt=0;t<tracks.length;t++)
{
if((!tracks_bool[t])&&(Math.abs(from_tracktracks[t])<min_dist)&&(t!=current_track_index))
{
to_track_index=t;
min_dist=Math.abs(from_tracktracks[t]);
//System.out.println("*fromtrack:"+from_track+":"+tracks[t]);
}
}
System.out.println("totrack:"+tracks[to_track_index]);//":"+min_dist);
total_cylinders+=Math.abs(from_tracktracks[to_track_index]);
tracks_bool[to_track_index]=true;
from_track=tracks[to_track_index];
current_track_index=to_track_index;
min_dist=max_dist;
}
System.out.println("Totalcylinderstraversed="+total_cylinders);
}
voidlook(intstart_track)
{
System.out.println("=======LOOK===========");
Stringdisknums[]=disk_sequence.split("");
inttracks[]=newint[disknums.length+1];
intp=0;
for(p=0;p<disknums.length;p++)
{
tracks[p]=Integer.parseInt(disknums[p]);
}
tracks[p]=start_track;
for(inti=0;i<tracks.length;i++)
{
for(intj=0;j<tracks.length1;j++)
{
if(tracks[j]>tracks[j+1])
{
inttemp=tracks[j];
tracks[j]=tracks[j+1];
tracks[j+1]=temp;
}
}
}
System.out.println("Aftersorting...");
inttotal_cylinders=0,from_track=start_track,to_track=0;
System.out.println("Traversingfrom:"+from_track);
inti=0;
for(i=0;i<tracks.length;i++)
{
if(tracks[i]==start_track)
break;
}
for(intx=i1;x>=0;x)
{
System.out.println("Totrack:"+tracks[x]);
to_track=tracks[x];
total_cylinders=total_cylinders+Math.abs(from_trackto_track);
from_track=to_track;
}
for(intx=i+1;x<tracks.length;x++)
{
System.out.println("Totrack:"+tracks[x]);
to_track=tracks[x];
total_cylinders=total_cylinders+Math.abs(from_trackto_track);
from_track=to_track;
}
System.out.println("Totalcylinderstraversed="+total_cylinders);
}
}
classos
{
publicstaticvoidmain(Stringargs[])throwsException
{
BufferedReaderbr=newBufferedReader(newInputStreamReader(System.in));
System.out.println("Enterdiskframesequence(separatedbyspace):");
//Stringframe_sequence=br.readLine();
Stringdisk_sequence="9818337122141246567";
System.out.println("Enterscanschedulingalgo:");
inti=Integer.parseInt(br.readLine());
System.out.println("Enterstartingtracknumber:");
inttrack=53;//Integer.parseInt(br.readLine());
DevMgmtm=newDevMgmt(disk_sequence);
if(i==1)
m.sstf(track);
else
if(i==2)
m.look(track);
}
}
Output
Enterdiskframesequence(separatedbyspace):
Enterscanschedulingalgo:
Enterstartingtracknumber:
=======SHORTESTSEEKTIMEFIRST===========
Traversingfrom:53
totrack:65
totrack:67
totrack:37
totrack:14
totrack:98
totrack:122
totrack:124
totrack:183
Totalcylinderstraversed=236
TYBSC
Computer Science
USCS504 & USCS604
Paper 4
Database Management
System & Softare
!ngineering
17Jul2013
1
PaperIV
DBMSII&SoftwareEngineering
SEMESTER V
DBMSII
17Jul2013
2
UNITI
Decomposition: Functional dependency, Closure of a
set of functional dependency, LosslessJoin set of functional dependency, Lossless Join
decomposition, Multi valued dependency and fourth
normal form, Join dependency, Fifth normal form.
Ref: [Ramakrishnam: 19.119.3, 19.5, 19.8]
Concurrency Control: Concept of a transaction, ACID
properties Serial and serializable schedules Conflict properties, Serial and serializable schedules, Conflict
and View serializabilty, Precedence graphs and test for
conflict seralizability.
Ref: [Ramakrishnam: 16.116.3, 17.1]
UNITII
Enforcing serializability by locks: Concept of locks, the
locking scheduler, Two phase Locking, upgrading and down
di l k C f d d l k C l grading locks, Concept of dead locks, Concurrency control
by time stamps, The Thomos Write rule.
Ref: [Ramakrishnam: 16.4, 17.1, 17.3, 17.4, 17.6]
Crash Recovery: ARIES algorithm. The log based
recovery, recovery related structures like transaction
and dirty page table, Writeahead log protocol, check y p g , g p ,
points, recovery from a system crash, Redo and Undo
phases.
Ref: [Ramakrishnam: 18.118.6]
17Jul2013
3
UNITIII
Fundamentals of PL/SQL: Defining variables and constants,
PL/SQL expressions and comparisons: Logical Operators,
Boolean Expressions, CASE Expressions Handling, Null
Values in Comparisons and Conditional Statements PL/SQL Values in Comparisons and Conditional Statements, PL/SQL
Datatypes: Number Types, Character Types, Boolean Type,
Datetime and Interval Types.
Ref: [Ivan Bayross: Chap 15]
Overview of PL/SQL Control Structures: Conditional
Control: IF and CASE Statements, IFTHEN Statement, IF
THENELSE Statement IFTHEN ELSIF Statement CASE THENELSE Statement, IFTHEN ELSIF Statement, CASE
Statement, Iterative Control: LOOP and EXIT Statements,
WHILELOOP, FORLOOP, Sequential Control: GOTO and
NULL Statements, Concept of nested tables.
Ref: [Ivan Bayross: Chap 15]
UNITIV
Sequences: creating sequences, referencing, altering and dropping a
sequence.
Ref: [Ivan Bayross: Chap 11]
Query evaluation: System Catalog, Evaluation of relational operators
like selection projection join and set introduction to query like selection, projection, join and set, introduction to query
optimization.
Ref: [Ramakrishnam: 12.112.4]
Cursors: Concept of a cursor, types of cursors: implicit cursors;
explicit cursor, Cursor for loops, Cursor variables, parameterized
cursors,
Ref: [Ivan Bayross: Chap 16] Ref: [Ivan Bayross: Chap 16]
Transactions in SQL: Defining a transaction, Making Changes
Permanent with COMMIT, Undoing Changes with ROLLBACK, Undoing
Partial Changes with SAVEPOINT and ROLLBACK, Defining read only
transactions, explicit locks: transaction and system level, Choosing a
Locking Strategy: ROW SHARE and ROW EXCLUSIVE Mode.
Ref: [Ivan Bayross: Chap 16,17]
17Jul2013
4
References
1) Ramakrishnam, Gehrke, Database Management Systems, McGraw Hill.
2) Ivan Bayross, SQL,PL/SQL The Programming language of Oracle,
B.P.B. Publications
3) Michael Abbey, Michael J. Corey, Ian Abramson, Oracle 8i A
Beginners Guide, Tata McGrawHill.
Addi i l f Additional Reference
1) Elsmasri and Navathe, Fundamentals of Database Systems, Pearson
Education.
2) Peter Rob and Coronel, Database Systems, Design, Implementation
and Management, Thomson Learning
3) C.J.Date, Longman, Introduction to database Systems, Pearson
Education.
4) Jeffrey D. Ullman, Jennifer Widom, A First Course in Database
Systems, Pearson Education.
5) Martin Gruber, Understanding SQL,B.P.B. Publications.
6) George Koch and Kevin Loney ,ORACLE The Complete Reference, Tata
McGraw Hill,New Delhi
7) P. S Deshpande Oracle SQL PL/SQL Black Book
SQL PL/SQLPracticals
Practical1: WritingPL/SQLblockswithbasic
programmingconstructsby
a.Sequentialstatement
b.unconstrainedloop
c.If..then..else,ifelsifelse..endif
Practical2: WritingPL/SQLblockswithbasic
programmingconstructs
a.casewhen
b.usingGOTOtojumpoutofloop
17Jul2013
5
DBMSIIPracticalProblems
Practical3:ProceduresinPL/SQL
a.Createanemptyprocedure
b Create a stored procedure and call it b.Createastoredprocedureandcallit
c.Defineproceduretoinsertdata
d.aforwarddeclarationofprocedure
Practical4:FunctionsinPL/SQL
D fi d ll f ti a.Defineandcallafunction
b.Defineandusefunctionsinselect/printstmt
c.Recursivefunction
d.callfunctionandstorereturntoavariable
DBMSIIPracticalProblems
Practical5:cursorswith
a.CursorAttributesforImplicitandExplicit
b.Types:ImplicitandExplicit
c.CursorForLoop
d.declare,open,fetchvaluesandclosecursor
Practical6:Cursorswith
a.Subqueries
b.Joins
c.Clauseslikegroupbywithhaving,orderby
withwhere
17Jul2013
6
DBMSIIPracticalProblems
Practical7:ExecutionofSequenceCommand
Usingalloptionsincludingcycle/nocycleand
nextvalandcurrval
Practical8:StudyofTransactionsandlocks
a.Commit,Rollback
b.Savepoint
SampleListofPracticalonGroup1
1.Createatablestudent_list(rollno,name,marks)
andgeneratethesequenceonrollno &display
2 Q i it llb k d 2.Queriesoncommit,rollbackcommands.
Sequences
3.WriteaPL/SQLblocktoupdatethepriceofthe
bookbyitstitle,ifprice>300thenupdateitby
10%,elseupdateitspriceby5%.Raisean
exception if book title not available exceptionifbooktitlenotavailable.
4.Writeapl/sqlblocktocallacursorinaprocedure.
Thisprocedureiscalledfromthepl/sqlblockand
resultisdisplayed.
17Jul2013
7
Questions???
SEMESTER VI
SoftwareEngineering
17Jul2013
8
WhatisinTY???
InSY,wecoveredphasesofSDLC,SSAD&
OOADApproach
In TY(Sem VI) we will be covering Project InTY(SemVI),wewillbecoveringProject
Management,ChangingtrendsinSoftware
Engineering&Testing
Testingshouldbecoveredinsuchawaythat
fortheprojectsitwillbeuseful(forex.Test
casesetc)AsSTLCstartsalongwithSDLC
Studentsshouldbetoldtosearchforprojects
fromthemonthofAugust
UNITI
RevisionofProjectManagementProcess
[Jalote2.4.1],RoleofProjectManager,Project
M t K l d A [S t i Ch 3 ManagementKnowledgeAreas[SatzingerChap3
(Pg99100,104)]
ManagingChangesinrequirements
[Jalote2.4.4]
RoleofsoftwareMetrics
[Jalote1.3.2,Pressman23.1.5]
ProjectScheduling:BuildingWBS,UseofGantt
andPERT/CPMChart
17Jul2013
9
UNITII
ConfigurationManagementProcess&Functionality&
Mechanism[Jalote2.4.3]
ProcessManagement,CMM&itslevels[Jalote2.4.5]
Risk Management & activities [Jalote5 6 15 6 3] RiskManagement&activities[Jalote 5.6.1 5.6.3]
ManagementofOOsoftwareProjects Objectorientedmetrics,
UseCaseEstimation[Pressman23.3.3(CKMetric
Suite),25.2.5,26.6.726.6.8,27.5.3][Somepartisrelatedto
testing*]
Selectingdevelopmenttools,IntroductiontoCASE[Satzinger
Chap2(Pg85 86 Pg 341)] Chap2(Pg8586,Pg341)]
UnifiedProcess,Itsphases&disciplines,
AgileDevelopment Principles&Practices,Extreme
programming Corevalues&Practices
[SatzingerChap16(Pg692705)]
UNITIII
SoftwareTesting:IntroductiontoQualityAssurance,SixSigma
[Pressman14.4.4,16.2,16.5.2]
TestingFundamentals,CommonTerms(likeError,Fault,
Failure,Bug,Crash)Objectivesoftesting,Challengesin
Testing Principles of Testing [Mustafa1 2 1 2 1 1 2 3 1 2 4 Testing,PrinciplesofTesting[Mustafa 1.2,1.2.1,1.2.3,1.2.4,
1.5],
StaticTesting Introduction&Principles
[Mustafa3.1,3.2]
TypesofTesting LevelsoftestingsuchasUnittesting,
Systemtesting,ValidationTesting,Acceptancetesting,
TypesoftestingsuchasBlackbox,WhiteBox,Functional,
Performance,Regression,Acceptance,Volume,Stress,Alpha,
Betatesting[Mustafa1.4]
PlanningSoftwareTesting TestPlan,TestPlanSpecification,
TestCaseExecutionandAnalysis,Defectloggingandtracking
[Jalote10.4.210.4.5]
17Jul2013
10
UNITIV
BlackBoxTesting:Introduction,Equivalencepartitioning,
Boundaryvalue analysis, Robustness testing, Cause Effect Boundary valueanalysis,Robustnesstesting,CauseEffect
Graph,[Mustafa4.14.5,Jalote10.2.3]
WhiteBoxTesting :StatementCoverage,Branch/Decision
Coverage,ConditionCoverage,GraphMatrix,Cyclomatic
complexity,MutationTesting
[Mustafa5.15.6]
Object Oriented Testing & Web site testing Object Oriented ObjectOrientedTesting&Websitetesting ObjectOriented
TestingStrategies(*),Testingmethods,[Pressman19.3,
19.4.3,19.4.5,Mustafa11.2]Overviewofwebsite
testing[Pressman20.1.1]
References
1.SystemAnalysis&Design Satzinger,Jackson,Burd,Cengage Learning,
IndiaEd.
2.SoftwareEngineering APractitionersApproach,7
th
Edition,McGraw
HillInt.
3.IntegratedApproachtoSoftwareEngineering Pankaj Jalote (Narosa),
3
rd
Edition
4.DesignPatterns ElementsofReusableObjectOrientedSoftware,
PearsonBy ErichGamma,RichardHelm,RalphJohnson,JohnVlissides,
5.SoftwareTesting Concepts&Practices,Narosa,
Additional Reference
1) Design Patterns Elements of Reusable ObjectOriented Software, Pearson By
h Erich
Gamma, Richard Helm, Ralph Johnson, John Vlissides,
2) Software Engineering: Waman Jawadekar, TMH
3) Software Engineering : Sommerville, Pearson Education
17Jul2013
11
AdditionalReferencesforprojects
UMLForJavaProgrammers RobertMartin
DesigningFlexibleObjectOrientedSystems
withUML CharlesRichter
BuildingWebApplicationswithUML Jim
Connalen
ASPNET 3 5 Application Architecture & ASP.NET3.5ApplicationArchitecture&
Design VivekThakur
ProjectDiscussion
?????
17Jul2013
12
Questions???
ThankYou!!