|
By shoyebkhan
CS-63 Solved Assignment 2012
Presented by http://www.myignou.in
Solved by Pradeep Kumar Rana, a student of IGNOU BCA 6th semester. His facebook URL= http://www.facebook.com/people/Pradeep-Rana/100001389169424
Course Code : CS-63
Course Title : Introduction to System Software
Assignment Number : BCA (3)-63/Assignment/2012
Maximum Marks : 25
Last Date of Submission : 30th April, 2012/30th October, 2012
There are seven questions in this Assignment. Answer all the questions. You may use illustrations and diagrams to enhance explanation.
1) Consider the following set of processes that arrive in the ready queue at the same time:
Process CPU time
P1 2
P2 5
P3 2
P4 1
P5 4
Consider the following scheduling algorithms:
First Come First Serve (FCFS), Shortest job first (SJF) and Round Robin (quantum = 1)
What is the turnaround time of each process for each of the above scheduling algorithms?
What is the waiting time of each process for each of the above scheduling algorithms? (3 Marks)
ANS:-FCFS (first come first serve)
Process CPU time Waiting time Turn around time=
CPU time+w.t
P1 2 0 2
P2 5 2 7
P3 2 7 9
P4 1 9 10
P5 4 10 14
TOTAL 14 28 42
Average waiting time=28/5=5.6
Average turn@time=42/5=8.4
SJS(Shrtage job first)
Process CPU time Waiting time Turn around time=
CPU time+w.t
P1 1 0 1
P2 2 1 3
P3 2 3 5
P4 4 7 11
P5 5 13 18
TOTAL 14 24 38
Average waiting time=24/5=4.8
Average turn@time=38/5=7.6
Round robin scheduling, quantum=1
Process CPU time Waiting time Turn around time=
CPU time+w.t
P1 2 4 6
P2 5 9 14
P3 2 6 8
P4 1 3 4
P5 4 9 13
TOTAL 14 31 45
Average waiting time=31/5=6.2
Average turn@time=45/5=9
2) Write a shell program to convert a decimal number to its hexadecimal equivalent.
(4 Marks)
ANS:- clear
echo “ enter the binary number which you want to convert”
read bin
binary=$bin;
while[$bin –gt 0]
do
result=`expr $bin % 10000`
bin=`expr $bin / 10000`
dec=0
i=1
while[$result –gt 0]
do
b=`expr $result % 10`
dec=`expr $dec + $b \* $i`
result=`expr $result / 10`
i=`expr $i \* 2`
done
if[$dec –ge 0 –a $dec –le 9]
then
dec1=$dec
slif[$dec –eq 10]
then
char=”A”
elif[$dec –eq 11]
then
char=”B”
elif[$dec –eq 12]
then
char=”C”
elif[$dec –eq 13]
then
char=”D”
elif[$dec –eq 14]
then
char=”E”
elif[$dec –eq 15]
then
char=”F”
fi
hex=$char$hex
done
echo “the binary $binary number after convert into hexa $hex”
3) Construct Context Free Grammar for the “While” and “Switch” Statement of C Language. (4 Marks)
Ans:-WHILE loop: -
The general form of which is as shown below:
While control command
do
Command 1
Command 1
done
Example
$vi
count=1
while[$count -le 5]
do
echo”$count”
count=`expr $i + 1`
done
press esc+:wq (save and quit from vi editor) after that we have to run the programe
$sh count
Switch:-
Switch ? option? String pattern body pattern? Pattern body…?
The switch command is the direct analog of the unixshell case satatement and the c switch. The general form of the case control instruction is given belw:-
Case value in
Choice1)
do this a
and this
Choice2)
do this a
and this
Choice1)
do this a
and this
::
*0
D0 this
Esac
Example
Echo”enter a number from 1 to 3”
Read num
Case $num in
1)echo ”you entered 1”
2) echo ”you entered 2”
::
3) echo ”you entered 2”
::
*) #degault case
echo |said 1 to 3
::
esac
4) Compare and contrast the important features of the WINDOWS VISTA and UBUNTU (Linux) operating system. (3 Marks)
Answer:
Comparison
Vista and Ubuntu have roughly the same installation procedure. Pop in the installation disc, boot the computer, and run the setup process (which can take an hour or more). Both OSes let you manually choose disk partitioning schemes for an existing disk, or have the computer wipe everything down and sort things out.
Ubuntu makes it far easier to deal with hardware than previous, less user-friendly versions of Linux did, but only up to a point. The most common types of hardware and usage scenarios are handled the best, but the further you drift from that, the more complicated it gets. At its worst, Ubuntu's way of dealing with hardware often involves manual hacking to accomplish things that ought to be trivial (and in Windows usually are).
Vista's way of dealing with hardware is pretty centralized -- the Device Manager lets you browse all the installed hardware in a system, manage each device's driver and configuration, and so on. Ubuntu has a device manager, but it's just a static list, and can't be used for configuring devices per se. To do that, you often need to edit a configuration file, and the exact file to edit may depend on the type of device.
Ubuntu has two basic ways to deal with adding software: the the Add/Remove Applications tool (easy) and the Synaptic Package Manager (for experts). Add/Remove Applications lets you search the entire directory of applications recommended for Ubuntu -- dozens of programs in 11 categories -- and install them with little effort. I added applications like Adobe Reader and the Thunderbird mail client without too much difficulty. It all compares pretty favorably to Windows's Add/Remove Programs system, which should be familiar to everyone reading this.
Ubuntu comes configured by default with several programs for multimedia: Sound Juicer, for ripping audio from CDs into the FLAC or OGG formats; Rhythmbox, for organizing music and creating playlists (the closest thing to Windows Media Player, really); Serpentine, for authoring audio CDs; and Movie Player and Sound Recorder, which are self-explanatory.
Playing MP3s, however, is not something you can do out of the box. It wasn't immediately clear what I could do to fix that, but after some research I found a separate codec pack (called the Gstreamer Plugins package) which solved the problem. Evidently Ubuntu can't be distributed with the MP3 codecs due to licensing restrictions.
Vista's multimedia components consist of Windows Media Player 11 (WMP) -- best for playing music or whatnot while doing other things -- and Windows Media Center, which is useful if you're using the PC as the center of your entertainment system. WMP has come a long way since its earlier, clunkier incarnations, and version 11 has a lot of things I have come to like. For example, I have a pretty large music library (over 100GB) that I keep ripped to the PC, and WMP's indexed search system lets you find a particular artist or song very quickly. One drawback to WMP is that out of the box it only rips to Microsoft's own WMA format, WAV, or to plain old MP3; the patent-free AAC and Ogg Vorbis formats aren't natively supported for ripping.
Contrast
Ubuntu installation is easier and faster. There are Free upgrades available every 6 months. It is an open source operating system, free to download and install.
Vista takes longer to install with many updates required before installation is completed. There are paid upgrades from one version to another. Each version has own specific features which can be confusing for a beginner.
Ubuntu is one of the safest operating systems around as no ports are open by default which is one of the main hacking breaches other operating systems suffer.
Ubuntu by default does not offer access to the root directories to be modified, unlike VISTA, making Ubuntu safer and more stable as an operating system.
Ubuntu offers more than 16,000 different packages are available for free which is mind blowing.
In Vista Number of applications & features vary depending on the Vista versions.
Vista Command Prompt is not even comparable to Ubuntu Shell. Ubuntu Shell is very powerfull and give you the ability to perform all of your tasks easily without the need for GUI. Windows Command prompt is very limiting. That gives Ubuntu a better edge in automating tasks than Vista.
Ubuntu is capable of downloading and installing updates automatically without being attended to.
Vista: Registration is required. Popup gives options about downloading available updates.
Ubuntu: Ubuntu gives lesser trouble with 64Bit configuration. Hardware performance tools are unnecessary with Ubuntu as it is a very stable OS.
Vista: Inbuilt hardware assessment tool for hardware optimization. Crashes are common.
5) Write a shell program to find the sum of the alternate digits in a given 5 digit number. Also, draw a flow chart for the program. (4 Marks)
ANS:- i=o
echo “Enter a 5 digit number”
read num
n=1
while [ $n -le 5 ]
do
a=`echo $num | cut -c $n`
i=`expr $a + i`
echo $i
n=`expr $n + 2`
done
6) Discuss the advantages and disadvantages of using stream-oriented approach in UNIX system rather than record-oriented approach. (3 Marks)
Answer: coming soon
7) Write the UNIX commands for the following tasks:
(a) To print location of first difference after comparing 2 files.
(b) To search files for lines that match a particular string pattern given.
(c) To search for a given pattern in a file and display its count.
(d) To append the contents of file1, file2 to file3. (4 Marks)
(A) ANS:-
(B) ANS:- $greap “pattern” filename
(C) ANS:-$greap -v “pattern” filename
(D) ANS:-cat file1 file2 file3
|