UNIX/Linux Programming Answers

Questions: 170

Answers by our Experts: 135

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Write a bash script to simulate producer-consumer problem using semaphores.

Producer-consumer problem is a common paradigm for cooperating processes. A producer process produces information that is consumed by a consumer process. One solution to the producer-consumer problem uses shared memory. To allow producer and consumer processes to run concurrently, there must be available a buffer of items that can be filled by the producer and emptied by the consumer. This buffer will reside in a region of memory that is shared by the producer and consumer processes. A producer can produce one item while the consumer is consuming another item. The producer and consumer must be synchronized, so that the consumer does not try to consume an item that has not yet been produced


Write a bash script to simulate producer-consumer problem using semaphores.

Producer-consumer problem is a common paradigm for cooperating processes. A producer process produces information that is consumed by a consumer process. One solution to the producer-consumer problem uses shared memory. To allow producer and consumer processes to run concurrently, there must be available a buffer of items that can be filled by the producer and emptied by the consumer. This buffer will reside in a region of memory that is shared by the producer and consumer processes. A producer can produce one item while the consumer is consuming another item. The producer and consumer must be synchronized, so that the consumer does not try to consume an item that has not yet been produced


Schedule a backup to be taken at 11.59pm from monday to friday /etc directory and backup file need to be archived and compressed.These backups need to be stored in /backup directory.
Below is a sequence of shell commands that we typed into a bash terminal window on a Linux machine and some of the output that was produced. Your job is to write the output produced by the commands in the sequence. The commands are executed consecutively and changes made by one command may affect the output produced by later commands.

First Make a Directory and Rename as Name_AridNo like (Shouzab_17-Arid-2045) and create all other necessary files and then execute the following commands and show output.

Shell > pwd /home/me/test

> ls -F hw1 hw1.bak tmp/

> bash

> touch it

> cd tmp

> ls -F justme.txt

> echo "Dear Shouzab" > diary

> cat 'Name_AridNo' /Shouzab_17-Arid-2045/hosts

> pwd
You are working on a documentation file userNotes.txt with some members of your software development team. Just before the file needs to be submitted, you manager tells you that a company standard requires that two blank spaces be left between the end-of-sentence period (.) and the start of the next sentence. (This rule does not affect sentences at the very end of a line.)

For example, this is OK: Turn the knob. Push the “on” button.
This is not: Turn the knob. Push the “on” button.
Asking around among your team members, you discover that some of them have already typed their sentences in the approved manner, but others have inserted only a single blank between sentences.

You need to fix this fast, and the first thing you want to do is to find out how bad the problem is.

What command would you give to list all lines of userNotes.txt that contain sentence endings with only one blank before the start of the next sentence?

hlo, i need help in DNS Server Configuration with BIND Assignment i want to your inssitance

Log all the work you do in the bash shell using the script command (see the “Session
Logging” section below). You will need to get logging working BEFORE you perform any of
the steps listed below. You will need to turn in the session log files. See “Deliverables” below.
With script logging on and working, write a program that consists of two C++ source files and
a header file (.h file). The first C++ file contains the main() routine and the second file contains a
C++ function. The function prototype should be included in the header file.
From within main(), you must display the count of command line arguments to stdout.
Further, you must display the value of each command line argument to stdout. Finally,
you must call the procedure that is defined in the second file.
From within the procedure defined in the second file, you must display a log message that
states you are inside the procedure. This log message must be sent to stderr.
Create a shell script which prints the line contents when the line number is divisible by 3 from an input file. Assume the first line is line 1. At the end of the script, if the total number of lines divisible by 3 is greater than 10, print “big”. Otherwise, print “small”.

I need help in answering this question. so far this is what I have

echo $1

file=$1

awk 'NR%2==0' $file

count=$(wc -l $file | grep -o "^[0-9]")

if [ $count -gt 20 ]
then
printf "\nbig\n"
else
printf "\nsmall\n"
fi
Create a shell script which prints the line contents when the line number is divisible by 3 from an input file. Assume the first line is line 1. At the end of the script, if the total number of lines divisible by 3 is greater than 10, print “big”. Otherwise, print “small”.

I need help in answering this question. so far this is what I have

echo $1

file=$1

awk 'NR%2==0' $file

count=$(wc -l $file | grep -o "^[0-9]")

if [ $count -gt 20 ]
then
printf "\nbig\n"
else
printf "\nsmall\n"
fi
Write a program to implement Peterson’s solution for Critical
Section problem.
LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS