Академический Документы
Профессиональный Документы
Культура Документы
#main()
{
printf "user profile \n"
printf "Enter name:"; read name;
printf "Enter roll number:"; read no;
printf "Enter branch:"; read bra;
printf "Enter mobile number:"; read mo;
printf "Enter address:"; read ad;
printf "Enter pincode:"; read pin;
OUTPUT:
mint@mint:~$ sh a.sh
user profile
Enter name:palanisamy
Enter roll number:106mc159
Enter branch:mca
Enter mobile number:9500203185
Enter address:403 kamaraj street
Enter pincode:638502
RESULT:
Thus the program executed and verified result successfully by using shell
programming.
VIVA QUESTIONS:
1. What do you mean by operating system?
Operating system is the software that controls the computer hardware. It
acts as an interface between computer hardware and the user.
4. What is Kernal?
Kernal is the central part of the UNIX OS. It encapsulates the hardware
and provides UNIX system services to applications programs.
8. What is Shell?
The Shell is the UNIX system’s mechanism for interfacing between users
and the system. It is a command interpreter.
new()
{
echo "Enter file name to create"; read name;
clear
echo ''>$name;
while :
do
read a
case $a in [qQ]|[qQ][uU][iI][tT]) break;;
*) echo $a>>$name;;
esac
done
}
display()
{
echo "Enter file name to open"; read name;
if test [-f $name]
then
uniq $name;
fi
}
canc()
{
echo "Enter file name to append"; read name;
clear
uniq $name;
while :
do
read a
case $a in [qQ]|[qQ][uU][iI][tT]) break;;
*) echo $a>>$name;;
esac
done
}
#main()
{
while :
do
echo "\n\t\t menu\n\t\t----\n=> [1] Create\n=> [2] Display\n=> [3] Append\n=> [4]
Exit\nEnter choice...:"
read cmd
case $cmd in [1]) new;;
esac
case $cmd in [2]) display;;
esac
case $cmd in [3]) canc;;
esac
case $cmd in [4]) exit;;
esac
done
}
OUTPUT:
menu
----
=> [1] Create
=> [2] Display
=> [3] Append
=> [4] Exit
Enter choice...:
1
Enter file name to create
aa
menu
----
=> [1] Create
=> [2] Display
=> [3] Append
=> [4] Exit
Enter choice...:
2
menu
----
=> [1] Create
=> [2] Display
=> [3] Append
=> [4] Exit
Enter choice...:
3
Enter file name to append
aa
menu
----
=> [1] Create
=> [2] Display
=> [3] Append
=> [4] Exit
Enter choice...:
4
RESULT:
Thus the program executed and verified result successfully by using shell
programming.
VIVA QUESTIONS:
. What is process?
Ans: A process can be thought of as a program in execution. It is an active entity ,
with a
program counter specifying the next instruction to execute. The execution of a process
must
be sequential.
7. What are all the events may occur when process is assigned to CPU?
Ans:
1. The process could issue an I/O request, and then be placed in an I/O queue.
2. The process could create a new sub process and wait for its termination.
3. The process could be removed forcibly from the CPU, as a result of an interrupt,
and be put back in the ready queue.
AIM:
ALGORITHM:
CODING:
#include<sys/ipc.h>
#include<sys/msg.h>
#include<stdio.h>
void main()
{
int qid,i;
struct
{
long mtype;
char mtext[25];
}
message;
struct
{
long mtype;
char mtext[25];
}buff;
qid=msgget((key_t)3,IPC_CREAT|0666);
if(qid==1)
{
perror("Msgget Failed");
exit(1);
}
strcpy(message.mtext,"First Message");
message.mtype=1;
if(msgsnd(qid,&message,21,0)==-1)
{
perror("Msgsnd Failed");
exit(1);
}
strcpy(message.mtext,"Second Message");
message.mtype=2;
if(msgsnd(qid,&message,21,0)==-1)
{
perror("Msgsnd Failed");
exit(1);
}
strcpy(message.mtext,"Third Message");
message.mtype=3;
if(msgsnd(qid,&message,21,0)==-1)
{
perror("Msgsnd Failed");
exit(1);
}
qid=msgget((key_t)3,IPC_CREAT|0666);
if(qid==-1)
{
perror("Msgget Failed");
exit(1);
}
for(i=0;i<3;i++)
{
if(msgrcv(qid,&buff,15,0,IPC_NOWAIT|MSG_NOERROR)==-1)
{
perror("msgrcv failed");
exit(1);
}
printf("Message is %s\n",buff.mtext);
}
}
OUTPUT:
RESULT:
Thus the inter process communication using message queue was performed.
VIVA QUESTIONS:
$ echo *
It is similar to 'ls' command and displays all the files in the current directory.
ls stands for list; so it displays the list of the files that starts with 'chapter' with suffix '1' to
'5', chapter1, chapter2, and so on.
Yes, it stands for ‘disk usage’. With the help of this command you can find the disk
capacity and free space
of the disk.
9. How to terminate a process which is running and the specialty on command kill 0?
A pipe is two or more commands separated by pipe char '|'. That tells the shell to arrange for the
output of
the preceding command to be passed as input to the following command.
VIVA QUESTIONS:
There are four possible results from this call: ‘kill()’ returns 0. This implies that a process
exists with the given PID, and the system would allow you to send signals to it. It is system-
dependent whether the process could be a zombie.
AIM:
ALGORITHM:
#!/bin/sh
echo "Disk Hogs Report for System `hostname`"
bigdir2="`du -s /Library/* | sed 's/ /__/g' | sort -rn | cut -f2- | head -5`"
exit 0
OUTPUT:
RESULT:
Thus the program executed and verified result successfully by using shell
programming.
VIVA QUESTIONS:
Virtual memory systems separate the memory addresses used by a process from
actual physical addresses, allowing separation of processes and increasing the effectively
available amount of RAM using disk swapping. The quality of the virtual memory
manager can have a big impact on overall system performance.
a. Compile time
b. Load time
c. Execution time.
A buffer is a large block of memory from which blocks are allocated contiguously,
as a simple technique for fast allocation.
The Best fit allocates the smallest hole that is big enough. Entire list has to be
searched, unless it is sorted by size. This strategy produces smallest leftover hole.
First fit allocates the first hole that is big enough. Searching can either start at the
beginning of the set of holes or where the previous first-search ended. Searching can
be stopped as soon as a free hole that is big enough is found.
10. What is external fragmentation?
External fragmentation exists when enough total memory space exists to satisfy a
request, but it is not contiguous; storage is fragmented into a large number of small
holes.
Ex.No: 8 “ls -l” command
AIM:
ALGORITHM:
Coding:-
lsl()
{
ls -l > a
uniq a
rm a
}
#main()
{
lsl
}
OUTPUT:
mint@mint:/media/Amp/unix$ sh lsl.sh
total 480
-rwx------ 1 mint root 0 2011-01-30 17:54 a
-rwx------ 1 mint root 88 2011-01-29 23:00 aa
-rwx------ 1 mint root 844 2011-01-29 21:33 ex3.txt
-rwx------ 1 mint root 670 2011-01-29 23:31 ex41.sh
-rwx------ 1 mint root 670 2011-01-29 23:31 ex41.sh~
-rwx------ 1 mint root 698 2011-01-29 23:27 ex4.sh
-rwx------ 1 mint root 700 2011-01-29 23:26 ex4.sh~
-rwx------ 1 mint root 765 2011-01-29 23:00 ex4.txt
-rwx------ 1 mint root 765 2011-01-29 23:00 ex4.txt~
-rwx------ 1 mint root 308 2011-01-30 11:35 ex5.sh
-rwx------ 1 mint root 310 2011-01-30 11:33 ex5.sh~
-rwx------ 1 mint root 261 2011-01-30 11:37 expect.sh
-rwx------ 1 mint root 0 2011-01-30 11:38 in.fifo
-rwx------ 1 mint root 49 2011-01-30 17:52 lsl.sh
-rw------- 1 mint root 44 2011-01-30 17:52 lsl.sh~
-rwx------ 1 mint root 0 2011-01-30 17:53 lsl.tst
-rwx------ 1 mint root 0 2011-01-30 11:38 out.fifo
-rwx------ 1 mint root 277 2011-01-30 11:40 PIPE0
-rwx------ 1 mint root 1 2011-01-30 11:37 Unsaved Document 1~
RESULT:
Thus the program executed and verified result successfully by using shell
programming.
VIVA QUESTIONS:
Protection bits that are associated with each frame accomplish memory protection
in a paged environment. The protection bits can be checked to verify that no writes are
being made to a read-only page.
When the bit is set to valid, this value indicates that the associated page is in
the process’s logical address space, and is thus a legal page. If the bit is said to
invalid, this value indicates that the page is not in the process’s logical address space.
Using the valid-invalid bit traps illegal addresses.
Virtual memory is a technique that allows the execution of processes that may not
be completely in memory. It is the separation of user logical memory from physical
memory. This separation provides an extremely large virtual memory, when only a
smaller physical memory is available.
In Demand paging, the pager brings only those necessary pages into memory
instead of swapping in a whole process. Thus it avoids reading into memory pages that
will not be used anyway, decreasing the swap time and the amount of physical
memory needed.
In Optimal algorithm, it replaces the page that will not be used for the longest
period of time. Optimal algorithm has the lowest page-fault rate of all algorithms.
Even though optimal algorithm has the smallest page fault-rate, it is difficult to
implement, because it requires future knowledge of the reference string. As a result, it
is used mainly for comparison studies.