1. If the data in memory are 10001100(in binary) which will be loaded into the registers by the following two loads in sequence (RISC-v assembly), show the content of register x1, x2, and x3 in hexadecimal respectively for the following instruction sequence. Assume that all registers are 32 bits. (20 pts)
(a) LB x1, 8(x0); load byte signed, x1 = ? (5 pts)
(b) LBu x2, 8(x0); load byte unsiged, x2 = ? (5 pts)
(c) ADD x3, x1, x2; x3 = ? (5 pts)
(d) What is the memory address for the data? (5 pts)

參考解答：
(a) 0xFFFFFF8C
(b) 0x0000008C
(c) 24
(d) 0x00000008
$\quad$
2. For single cycle implementation of a processor, draw the part of processor datapath for the memory instruction, such as LB, LW etc. (10 pts)

參考解答：

$\quad$
3. For a pipeline processor, answer the following questions: (10 pts)
(a) In the pipelined datapath, which components should be connected to the CPU clock? (5 pts)
(b) What is IPC? (5 pts)

參考解答：
(a) 略
(b) Inter-process communication or Instructions per cycle.
$\quad$
4. (a) For the IEEE 754 floating point standard of the single precision format, why is a bias of 127 added in the exponent field? (5 pts)
(b) What is the data format for 0.0? (5 pts)

參考解答：
(a) Make the exponent field unsigned will result in a faster comparison.
(b) 00000000000000000000000000000000 (32個0)
$\quad$
5. If a system does not employ either a deadlock-prevention or a deadlock-avoidance algorithm, then a deadlock situation may occur. In this environment, the system may provide an algorithm that examines the state of the system to determine whether a deadlock has occurred. If all resources have only a single instance, then we can define a deadlock-detection algorithm that uses a wait-for graph. Please describe the wait-for graph and how it detects deadlock. (10 pts)

參考解答：
A wait-for graph is a directed graph used for deadlock detection in operating systems and relational database systems.

In a wait-for graph, processes are represented as nodes, and an edge from process $P_{i}$ to $P_{j}$ implies $P_{j}$ is holding a resource that $P_{i}$ needs and thus $P_{i}$ is waiting for $P_{j}$ to release its lock on that resource. If a wait-for graph contains a cycle, then the system is in a deadlock state.
$\quad$
6. (a) Explain the terms “at most once” and “exactly once” and indicate how they relate to remote procedure calls. (5 pts)
(b) Describe two approaches to the binding of client and server ports during RPC calls. (5 pts)

參考解答：
(a) In RPC semantics:
• At most once: Request is processed 0 or 1 times.
• Exactly once: Request is always processed 1 time.
(b)
• Predetermined binding.
• Dynamically binding.
$\quad$
7. (a) Suppose we have the following page accesses: 1 2 3 5 2 3 4 1 2 1 1 3 1 4 and that there are three frames within out system. Using the FIFO replacement algorithm, what will be the final configuration of the three frames following the execution of the given reference string? (5 pts)
(b) Given the reference string of page accesses: 1 2 3 4 2 3 4 1 2 1 1 3 1 4 and a system with three page frames, what is the final configuration of the three frames after the LRU algorithm is applied? (5 pts)

參考解答：
(a) 4, 3, 2
(b) 4, 1, 3
$\quad$
8. The following process are being scheduled using a preemptive, round-robin scheduling algorithm. Each process is assigned a numerical priority, with a higher number indicating a higher relative priority. In addition to the process listed below, the system also has an idle task (which consumes no CPU resources and is identified as Pidle). This task has priority 0 and is scheduled whenever the system has no other available processes to run. The length of a time quantum is 10 units. If a process is preempted by a higher-priority process, the preempted process is placed at the end of the queue.
 Process Priority Burst Arrival P1 40 20 0 P2 30 25 25 P3 30 25 30 P4 35 15 60 P5 5 10 100 P6 10 10 105

(a) Show the scheduling order of the process using a Gantt chart. (5 pts)
(b) What is the turnaround time for each process? (5 pts)
(c) What is the waiting time for each process? (5 pts)
(d) What is the CPU utilization rate? (5 pts)

參考解答：
(a)

(b)
P1: 20
P2: 55
P3: 60
P4: 15
P5: 20
P6: 10
(c)
P1: 0
P2: 30
P3: 35
P4: 0
P5: 10
P6: 0
(d)
87.5%