C Programming, System programming, Process creation
$10-30 USD
Σε Εξέλιξη
Αναρτήθηκε περίπου 8 χρόνια πριν
$10-30 USD
Πληρωμή κατά την παράδοση
Problem 1.
Develop a program named ProcessTree.c. When the program is run, it accepts
four command line arguments, denoted as h, m, s and d respectively.
The program should create mulitple processes form a binary tree of height
h. Let us identify these processes using integers 0, 1, · · · , 2h+1 −2 such that: (i)
the process on the root is identified as 0; (ii) if the process identified as y is a
child of the process identified as x, then y = 2x + 1 (left child) or y = 2x + 2
(right child). Among these processes, two can communicate with each other iff
they are parent and child. You are required to use system calls fork and pipe
for process creation and inter-process communication.
Then, given that arguments m is a string while s and d are integers from
{0, · · ·, 2h+1 − 2}, the process identified by s should send string m to the process
identified by d via one or multiple pipes connecting the processes. During
the course that string m is being sent, forwarded and received, every involved
process should output its identify.
Problem 2.
Develop a program named ProcessForest.c. As in Problem 1, when the program
is run, it accepts four command line arguments, denoted as h, m, s and
d.
The program should create two binary trees of processes where each process
is identified by a pair (treeID, processID), where treeID is either 0 or 1, and
within each tree, the processID of each process is determined in the same way
as in Problem 1. Among these processes, each pair of processes that are parent
and child on a tree can communicate with each other via pipe, and the two root
nodes can communicate with each other through a shared memory block (Note:
1
you should use the POSIX shared memory library to create and manage the
block).
The argument m is a string, s and d are two pairs s = (s0, s1) and d = (d0, d1)
where s0 and d0 are selected from {0, 1} while s1 and d1 are selected from
{0, · · ·, 2h+1 − 2}. The process identified by s should send string m to the
process identified by d hop by hop. During the course that the string m is being
sent, forwarded and received, every involved process should output its identity.
Problem 3.
Develop a program name T hreadMapper.c. The program will be compiled together
with (user-providing) functions named func1, func2 and func3, each of
which has the signature of int func() and may call a function named void yield()
whose functionality is to be explained later. The functionality of ThreadMapper
is as follows:
• First, for each of the functions func1, func2 and func3, a user thread
that can run the function is created by initializing a context for the user
thread.
• Second, store these contexts into a queue.
• Third, adopt the many-to-one mode to execute the user threads according
to their orders in the queue. When a running user thread calls yield(), it
should be unmapped from the kernel thread; its context should be saved
and appended to the tail of queue, waiting for the next turn that it will
be executed again.
Hi,
I am quite familiar and experienced in unix process programming using POSIC threads and can complete the assignment in 12 hours time.
Please contact me as soon as possible if you need my help.
With Regards,
Koustav