Вы находитесь на странице: 1из 3

Philip

Yun 65035200 1
CS 143a S16
1. Question 1: Polling, Interrupts and Traps
a. Polling is a low level process where CPU will periodically check external hardware
to check the current state of that service. Interrupts on the other hand, are
signals by processes to the processor alerting that I/O is available or a higher
priority process is required to run before other ones. Polling is different because
it requires overhead to continuously check I/O on a time basis. When no
requests are queued, polling still takes place. Interrupts are slightly more
efficient because it will send a signal once i/o is finished. Only one check
happens versus the periodic checks made by polling.
b. 60 Words/min * 4chars/word *min/60sec = 4 chars a second.
4 chars/second * second/1 Billion. Every 4 chars, 1 Billion instructions are
executed. Thus, 250 million instructions are executed during the time one char
is typed
c. Asynchronous I/O is interrupt driven. A signal is dispatched when I/O has
finished
d. Trap: Software generated interrupt caused by an error or user request
Interrupt is a lower level signal generated by hardware rather than an error or
user driven signal.
2. Question 2: Parallel, Distributed, Real-Time Systems
a. Timesharing is an equal based system to run multiple programs. A timer is set
and when the timer hits 0, an interruption occurs to swap processes.
Multiprogramming also uses interrupts, but dont have a timer. Programs run
until an interruption from another process occurs.
b. Network routers are distributed systems. They require multiple routers to be set
up so that way computers on different networks can transmit data from one
network to another. Each router has the same goal but runs in different
locations, despite running the same task.
Multiplayer Video Games also have distributed computing. Multiple servers will
be set up to process many users requests. Although many servers exist, each
server works to process and send the players moves, etc across to other players
so that multiple game rooms can be running at the same time.
c. Hard/Soft real time
Spotify
Soft real time
Android System Interface
Hard real time
Adaptive Cruise Control
Hard Real time
HiFreq Stock Trading
Hard Real Time

Spotify is soft real time as it does not require precise time precision to execute
requests.
Android OS should be hard real time, as it needs to be able to accept calls and
notifications in real time.
Cruise control needs to be hard real time so that it can adapt to environmental
changes in real time, for the safety of the passengers

Philip Yun 65035200 2


CS 143a S16
Stock trading must be in hard real time, because if you buy/sell stocks at the
wrong time, you could lose money quickly.

3. Question 3: System Calls
a. SysCalls and Parameters
i. size_t read(int fd, void * buf, int count)
1. fd is a file descriptor
2. buf is the storage unit
3. count is the number of bytes to read from file descriptor fd
4. returns number of bytes read (could be less than count)
ii. pid_t wait(int* status)
1. the status parameter is a pointer to an int representing a status
code of a process.
2. It returns a pid_t , which is an int that represents the status of a
child process
iii. Int fork()
1. Fork takes no parameters
2. Fork returns an int signifying the status of the parent and the
forked process
b. To write a program that opens a file and writes to another file the same
contents, you would need open(), read(), write() and close() syscalls.
c. Privileged Operations
Searching String for sequence
No
Generate an Interrupt
Yes
Process Hardware Interrupt
Yes
Check List of currently running processes
No
Access network card buffer
Yes
4. Question 4: Processes
a. Modified state figure

Philip Yun 65035200 3


CS 143a S16
b. Process Control Block
CPU Registers
Yes
Number of Processes
No
Program Counter
Yes
Process ID
Yes
File Permission
No
5. Question 5: Threads
a. Threads are faster to create than processes, because they dont need to create,
copy or allocate space for memory, as all memory in threads is shared with the
parent thread.
b. Multithreaded servers benefit from the usage of threads because if multiple
people are trying to request a connection from a server, the server can handle all
of them concurrently. For each request that is made with the server, the server
can create a new thread for each client and process each thread for each client,
then destroy the thread after the clients request has been completed
c. User level threads dont occur at the operating system level and dont require
much overhead than the Kernel level threads do. Kernel threads guarantee
threads on different cores and processors making the overhead larger. Because
kernel threads are much more expensive, thread switching is more expensive
with kernel threads than user threads are.
d. Shared resources in threads:
Memory
Shared
Program Counter
Private
Execution stack
Private
Global Variables
Shared

Вам также может понравиться