Forum     

Go Back   Digit Technology Discussion Forum > Software > Open Source
Register FAQ Calendar Mark Forums Read

Open Source A place where you can talk to like-minded people about the fastest growing software movement today! Discuss anything and everything about Open Source software and Operating Systems.


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 04-12-2005, 12:50 PM   #1 (permalink)
In The Zone
 
Join Date: Jul 2005
Posts: 264
Default Need some LINUX answers


Need the commands n shell progs:

1. Display all the files in your current directory in upper case.
2. Display all the files with all attributes those have been created and modified in the month of August.
3. Write a shell script to read date and temperature of last 7 days and show the average temperature of last 7 days.
4. Write a shell script to make a calculator.
5. Write a program to send message through pipe.
6. Write a program for FCFS CPU scheduling algo.
7. Write a program for SJF CPU scheduling algo.

Plz help.
ra_sriniketan is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 04-12-2005, 11:09 PM   #2 (permalink)
Wise Old Owl
 
vignesh's Avatar
 
Join Date: Jul 2004
Location: Chennai
Posts: 1,659
Default

This looks like my OS lab practicall exam..
I know only one answer now.

2. ls -t time value (in days)
vignesh is offline  
Old 05-12-2005, 01:01 PM   #3 (permalink)
Alpha Geek
 
Satissh S's Avatar
 
Join Date: Mar 2005
Location: Chennai , India
Posts: 693
Default

@vignesh: CSE ?? Which year? Me 1st year!! Cheers!!
Satissh S is offline  
Old 05-12-2005, 03:22 PM   #4 (permalink)
Wise Old Owl
 
vignesh's Avatar
 
Join Date: Jul 2004
Location: Chennai
Posts: 1,659
Default

I am in the 3rd year..
vignesh is offline  
Old 05-12-2005, 07:16 PM   #5 (permalink)
FooBar Guy
 
GNUrag's Avatar
 
Join Date: Jun 2004
Location: GNUmbai
Posts: 1,245
Default Re: Need some LINUX answers

You'll learn a lot from these articles written by nixcraft.
http://www.freeos.com/guides/lsst/ch08.html

Quote:
Originally Posted by ra_sriniketan
1. Display all the files in your current directory in upper case.
$ ls | tr 'a-z' 'A-Z'

Quote:
Originally Posted by ra_sriniketan
2. Display all the files with all attributes those have been created and modified in the month of August.
ls -l | grep "2005-08-[00-31]"

Quote:
Originally Posted by ra_sriniketan
3. Write a shell script to read date and temperature of last 7 days and show the average temperature of last 7 days.
4. Write a shell script to make a calculator.
Something along these lines...
Code:
#!/bin/bash

echo -n "Enter value for a: "
read a
echo -n "Enter value for b: "
read b


echo -n "Add[a] , Sub[s], Mult[m], Div[d]: "
read oprn

if [ $oprn == "a" ]; then
        ANS=`echo $a + $b | bc`
elif [ $oprn == "s" ]; then
        ANS=`echo $a - $b | bc`
elif [ $oprn == "m" ]; then
        ANS=`echo $a * $b | bc`
elif [ $oprn == "d" ]; then
        ANS=`echo $a / $b | bc`
fi

echo "Answer : $ANS "
Quote:
Originally Posted by ra_sriniketan
5. Write a program to send message through pipe.
echo "Test message" | cat -

Quote:
Originally Posted by ra_sriniketan
6. Write a program for FCFS CPU scheduling algo.
7. Write a program for SJF CPU scheduling algo.
What on earth does FCFS/SJF means?


Quote:
Originally Posted by ra_sriniketan
Plz help.
Plz, credit Rs. 1000/= to my ICICI bank account if above was useful
__________________
- --
http://web.gnuer.org
GNUrag is offline  
Old 05-12-2005, 09:30 PM   #6 (permalink)
In The Zone
 
Join Date: May 2004
Location: ** Hosur ** Operating System:GNU
Posts: 451
Default Re: Need some LINUX answers

Quote:
Originally Posted by GNUrag
What on earth does FCFS/SJF means?

FCFS - First Come First Serve
SJF - Shortest Job First

Both are Scheduling algorithms
__________________
Million's Of Open Minds Can't Be Wrong!
http://nc.xmgfree.com/weblog
Everybody Wants to go to Heaven...But nobody wants to Die! :wink:
naveenchandran is offline  
Old 06-12-2005, 11:13 AM   #7 (permalink)
FooBar Guy
 
GNUrag's Avatar
 
Join Date: Jun 2004
Location: GNUmbai
Posts: 1,245
Default Re: Need some LINUX answers

Quote:
Originally Posted by naveenchandran
FCFS - First Come First Serve
SJF - Shortest Job First
Cchhh... I know that...
I just didnt wanna write scripts for them
__________________
- --
http://web.gnuer.org
GNUrag is offline  
Old 12-12-2005, 11:05 PM   #8 (permalink)
String Phreak
 
mediator's Avatar
 
Join Date: Mar 2005
Location: In ur Evil Mind!
Posts: 2,457
Default

Hi There,
Well U can make FCFS/SJF in SHELL but during my first year I made it in c++.
Anyway You can also relate the c file to SHELL!


Here's the code for cpp file.

1. SJF :
*********
#include<iostream.h>
int n,time=0;
int *t=new int[n],*t1=new int[n];
int *arr=new int[n],*w=new int[n];

int sort(int pr[],int prt[],int c)
{

int i,tem,tem2,cmp=0;


for( i=0;i<(c-1);i++)
{
for(int j=(c-1);i<j;j--)
{
cmp++;
if(prt[j]<prt[j-1])
{
tem=prt[j]; tem2=pr[j];
prt[j]=prt[j-1]; pr[j]=pr[j-1];
prt[j-1]=tem; pr[j-1]=tem2;
}
else
continue;
}
}
return pr[0];
}



int sjf()
{
int i,j,c,*prt=new int[n],*pr=new int[n],proc;
for(i=0;i<time;i++)
{
c=0;
for(j=0;j<n;j++) //how many process r coming at i arrival time
{
if(arr[j]<=i && t[j]!=0)
{
pr[c]=j;
prt[c]=t[j];
c++;
}
else continue;
}
if(c==0) //If no process comes at i,increase waiting time
{
for(j=0;j<n;j++)
{
if(t[j]!=0 && arr[j]<i) w[j]++;
else continue;
}
}
else //else get the the shortest burst time t[] process
{
proc=sort(pr,prt,c);
t[proc]=0;
for(j=0;j<n;j++)
{
if(t[j]!=0 && arr[j]<i) w[j]++;
else continue;
}
}
}//end of time

return 0;
}


int main()
{
int i;
//cout<<"Enter the Number of Processes : "; cin>>n;
n=4;
t[0]=7;t[1]=4;t[2]=1;t[3]=4;
arr[0]=0;arr[1]=2;arr[2]=4;arr[3]=5;


for(i=0;i<n;i++)
{
w[i]=0;
t1[i]=t[i];
time=time+t[i];
}
sjf();
for(i=0;i<n;i++) cout<<"P["<<(i+1)<<"] "<<arr[i]<<" "<<t1[i]<<" "<<w[i]<<endl;

return 0;
}

********

U can compile the same in gcc under linux!

2. FCFS :
********
#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
int n,i;
cout<<"Enter number of processes : ";
cin>>n;
int *a=new int[n],*t=new int[n],*arr=new int[n];
clrscr();
cout<<"Process\t "<<"Arrival time\t"<<" Burst time";

for(i=0;i<n;i++)
{
gotoxy(1,i+3); cout<<"P["<<(i+1)<<"]";
gotoxy(17,i+3); cin>>arr[i];
gotoxy(38,i+3); cin>>t[i];
}
int *w=new int[n],*trn=new int[n],tot=0,tot1=0,avw=0,avtrn=0,*res=new int[n];
for(i=0;i<n;i++) { w[i]=0; res[i]=0;}
gotoxy(1,n+6);
cout<<"\t\tF I R S T C OM E F I R S T S E R V E";
gotoxy(1,n+7);
cout<<"\nProcess\t "<<"Waiting time\t"<<" Turnaround Time\t"
<<" Response time"<<endl;

for(i=0;i<n;i++)
{
if(i==0) {trn[i]=t[i];}
else
{
tot=tot+t[i-1];
w[i]=tot-arr[i];
trn[i]=w[i]+t[i];
}
tot1=tot1+t[i];
res[i]=tot1;
avw=avw+w[i]; avtrn=avtrn+trn[i];
gotoxy(1,i+n+10); cout<<"P["<<(i+1)<<"]";
gotoxy(17,i+n+10); cout<<w[i];
gotoxy(37,i+n+10); cout<<trn[i];
gotoxy(62,i+n+10); cout<<res[i];
}

cout<<"\nAverage waiting time = "<<((float)avw/n)<<endl;
cout<<"Average turnaround time = "<<((float)avtrn/n)<<endl;
getch();
return 0;
}
********
__________________
Bad Bad server.....No candy for u!
mediator is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by icebags
- by clinton
- by topgear
- by trublu

Advertisement




All times are GMT +5.5. The time now is 10:12 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2