Send a link to your students to track their progress
66 Terms
1
New cards
Unix does process creation/change using-
fork() and exec...()
2
New cards
What does fork1.c do?-
fork() then say hello
3
New cards
pid-
process ID
4
New cards
fork1a.c-
fork() and print pid
5
New cards
fork1b.c-
fork() and print relationship
6
New cards
fork2.c-
fork() twice creating 4 processes
7
New cards
fork3.c-
fork() thrice creating 8 processes
8
New cards
what happens when a parent forks-
creates a child class, calls exec(), exit(), wait(), then back to parent
9
New cards
mathtable.c-
uses 10 children to print ten lines of a multiplication table
10
New cards
in mathtable.c, how did the program wait before creating the next child-
wait(NULL)
11
New cards
can two process read and write from one pipe-
yes
12
New cards
do you have to close extra pipes if you allocate different pipes for reading and writing to different processes-
no
13
New cards
why would you close extra pipes if you allocate different pipes for reading and writing to different processes-
to prevent confusion of reading or writing a wrong pipe
14
New cards
guess3.c-
Parent and child processes communicate with each other using pipes, a special extension of file descriptors.
15
New cards
what happens if you create a pipes then fork-
the pipes get shared by the child
16
New cards
guess5.c-
switches user functionality to a different
17
New cards
What do the exec functions return on error?
-1
18
New cards
FD 0
Standard Input
19
New cards
FD 1
standard output
20
New cards
fd 2
error output
21
New cards
if pipes 0 1 and 2 are taken, what will a new pipes fds id be
3 and 4
22
New cards
what is the input pipe fds id
0
23
New cards
what is the output pipe fds id
1
24
New cards
guess6.c
reduced to do the pipe setup then fork(), then adjust thepipes using close() and dup(), theninvoke computer & user programs
25
New cards
if you need a 2nd input parameter what fds id would it be
3
26
New cards
mysum.c
uses multiple pipes between the addition child class
27
New cards
Assignment 8
calculator that uses many different pipes between the child classes that do the different processes. pipes are created dynamically based on where the data needs to go
28
New cards
ps -ef
Command to see every process on the system using standard syntax
29
New cards
ps -f
uid, pid, ppid, c (cpu), stime (start time), tty, time, cmd
30
New cards
popen()
Opens a pipe to read or write to
31
New cards
execvp
"parameters (const char *filename, char *const argv[]); searches directories listed in PATH environment to find full name of a file from filename; can execute system utility programs; array of pointers must be terminated by NULL poitner"
32
New cards
pclose()
Closes a pipe opened by popen() returns status
33
New cards
do unnamed pipes need to be created by common ancestors and passed to children
yes
34
New cards
what is the advantage of named pipes
does not need to be created by ancestors and can be used to connect any two processes
35
New cards
qserver.c & qclient.c
Server creates a named pipe and wait for requests from clients. Clients open server FIFO and send its own FIFOFor each client request, server opens specified FIFO and writes a quote & closes.
36
New cards
qserver2.c & qclient2.c
Avoid race conditions - good to include \n at the end of each lineMake server independent of client misbehavior by making the server wait for the client
37
New cards
qserver3.c & qclient3.c
Each client can ask for multiple quotes! But make the server work with old clients too.
38
New cards
qserver4.c & qclient4.c
Enable server and client to have a conversation:client can repeatedly specify quote number, server can respond....\n at end of each line and fflush() are needed to avoid buffering glitches.
39
New cards
how many clientfifos are needed if there are n clientes
n
40
New cards
how many serverfifos are there if there are n clients
1
41
New cards
Multiple writers for same pipe is OK, but what about multiple readers?
no
42
New cards
Assignment 10
hangman game that uses client and server fifos to get multiple client guesses at the same time
43
New cards
messages
IPC mechanism that uses servers and client to send an receive food
44
New cards
shared memory
In interprocess communication, a section of memory shared by multiple processes and used for message passing.
45
New cards
shmget()
create/recreate
46
New cards
shmat()
attach
47
New cards
shmdt()
detatch
48
New cards
shmctl()
change/remove
49
New cards
Unique key in shared memory
needed for the programs to create/access the shared memory
50
New cards
What do the exec functions return on success?
nothing
51
New cards
in guess 5 how does the child become a new process
execl()
52
New cards
socket() client or server
both
53
New cards
bind() client or server
both
54
New cards
recvfrom() client or server
client
55
New cards
read() client or server
client
56
New cards
close() client or server
both
57
New cards
listen() client or server
server
58
New cards
read() client or server
server
59
New cards
write() client or server
server
60
New cards
ps -ef
Shows all process ID
61
New cards
accept() client or server
server
62
New cards
Difference between TCP and UDP?
TDP is slow but secure while UDP is fast but not secure.