Os Lab Questions
Os Lab Questions
3) add a new directory to your PATH, and display the new path.
4) Write and execute shell script which uses the "date" command
and displays whether it is morning, noon, afternoon, evening or night.
Q1. Using awk find the number of users using /bin/sh and /bin/bash
cat /etc/passwd
libuuid:x:100:101::/var/lib/libuuid:/bin/sh
syslog:x:101:102::/home/syslog:/bin/bash
saned:x:110:116::/home/saned:/bin/bash
pulse:x:111:117:PulseAudio daemon,,,:/var/run/pulse:/bin/ksh
gdm:x:112:119:Gnome Display Manager:/var/lib/gdm:/bin/bash
Q2. With respect to the above file, what the following awk commands do?
What is the meaning of NF?
$ awk -F ':' '$3 > maxuid { maxuid=$3; maxline=$0 }; END { print maxuid, maxline }'
/etc/passwd
#!/bin/awk -f
BEGIN {
FS=":";
}
{
if ( $2 == "" ) {
print $1 ": no password!";
}
}
http://kirste.userpage.fu-berlin.de/chemnet/use/info/gawk/gawk_toc.html
3) See how use of the above three functions can make one to
write his/her own shell
Parent and child processes are usually independent and they execute in different
address space. However, there is a need to communicate between them to
perform many useful activities. pipe() is a system call to achieve this. This system
call is used for one-way communication.
https://www.tutorialspoint.com/inter_process_communication/inter_process_communication_pip
es.htm
https://www.tutorialspoint.com/inter_process_communication/inter_process_com
munication_named_pipes.htm
https://www.geeksforgeeks.org/named-pipe-fifo-example-c-program/
2) implement bounded buffer problem using shared memory and show that race
condition occurs.
(both Producer and the Consumer processes try to modify the same
variable).
3) Read about threads in the followimg document, and execute and understand
the program in Figure 26.2
http://pages.cs.wisc.edu/~remzi/OSTEP/threads-intro.pdf
https://www.tutorialspoint.com/inter_process_communication/inter_process_communica
tion_named_pipes.htm
https://www.tutorialspoint.com/inter_process_communication/inter_process_communica
tion_shared_memory.htm
1) Show using two threads accessing a common variable that race-condition can
occur.
-- build an interface in which different processes will request for memory with
certain sizes
-- Let the buddy system allocate a buddy for each request
-- display the state of the buddy allocator: Which buddies are free and which
are allocated. The display should be a nice form such that it is easy to
understand.
Implement the LRU replacement policy on top of the page based mM that you
implemented last time.
Please refer to
http://pages.cs.wisc.edu/~remzi/OSTEP/threads-sema.pdf
for use of semaphores.