select all the disadvantages of static relocation:
Difficult to grow heap and stack
No protection
External fragmentation
Internal fragmentation
Assistant
Here are the disadvantages of static relocation from your list:
Difficult to grow heap and stack
No protection
Static relocation does not directly cause external fragmentation or internal fragmentation, as these issues refer more to how memory is allocated and used during the dynamic allocation and deallocation of memory blocks. Static relocation mainly refers to adjusting the addresses in a program so that it can be loaded into a specific area in memory before execution begins, and it does not handle dynamic size changes nor protect against errors like buffer overflows or accessing unauthorized memory regions.
User
select all the disadvantages of static relocation:
a. Difficult to grow heap and stack
b. No protection
c. External fragmentation
d. Internal fragmentation
Assistant
The disadvantages of static relocation from the options provided are:
a. Diffapericult to grow heap and stack - Static relocation fixes the addresses at which programs will load in memory before execution starts, making it inflexible when it comes to dynamically resizing runtime structures like the heap and stack.
b. No protection - Since the memory locations are fixed and the program doesn't adapt those based on execution requirements or other concurrently running programs, static relocation does not offer protections against errors such as writing out of bounds of allocated memory space, or against malicious disruptions like a buffer overflow. This fixed nature can expose programs to security vulnerabilities.
Thus, choices a and b are the correct disadvantages of static relocation from the provided list.
User
On system with only base register without bounds register, can process P1 access P2 memory? P1's base=0x2000, P2's base=0x6000
Assistant
In a system where only a base register is used without a bounds register, the primary function of the base register is to indicate the starting address of the program in physical memory. A bounds register, by contrast, would normally provide the upper limit of the memory that the program is allowed to use, thereby offering protection against accessing memory outside its designated range.
In the scenario where the system only employs a base register and lacks a bounds register, the following observations apply:
User
On system with only base register without bounds register, can process P2 access P1 memory? P1’s base=0x2000, P2’s base=0x6000
Assistant
Yes, on a system using only a base register without a bounds register, it is technically possible for Process P2 to access the memory of Process P1 under certain conditions. Let's break down the situation:
Base Register Role: The base register in each process sets the starting point of its memory allocation. For P1, it's 0x2000, and for P2, it's 0x6000.
Lack of Bounds Checking: Without a bounds register or another form of memory protection (like memory management unit controls), there is no system-level enforcement to prevent a process from accessing memory addresses outside its intended range.
Potential for Memory Access: If P2, starting at 0x6000, performs an operation pointing to a memory address below its base (e.g., by using negative or wrapped-around address calculations), it could potentially access the memory space allocated to P1. This would depend on how addressing and address interpretation are handled in the system.
User
On system with only base register without bounds register, can process P2 access P1 memory? P1’s base=0x2000, P2’s base=0x6000
Assistant
In a system using only a base register without a bounds register, the enforcement of memory isolation solely depends on other operating system mechanisms or policies. Without additional context such as whether there is any rudimentary memory management beyond the base register, the assumptions can vary. Here, we'll consider the scenario under simple, direct assumptions:
User
With pure segmentation (with no paging or TLBs), fetching and executing an instruction that performs a store from a register to memory will involve how many memory accesses?
Assistant
User
With pure segmentation (with no paging or TLBs), fetching and executing an instruction that performs a store from a register to memory will involve how many memory accesses?
Assistant
In a system with pure segmentation, the process of fetching and executing an instruction that writes data from a register to a memory location generally involves several steps, each of which may require accessing memory. To accurately illustrate this, here's a breakdown for a typical store instruction in such a setup:
User
how about reading data from register?
Assistant
User
In the workload below, how des the temporal locality of the process change with increasing value of N?
int sum=0;srand(8192);for(int i=0;i<10000;i++)sum+=arr[rand()%N];
Assistant
User
With large page sizes, what happens to following metrics? [select]=increase/decrease/doesn't change:
TLB hit rate
[ Select ]
Internal fragmentation
[ Select ]
Size of page tables
[ Select ]
Assistant
When considering the implications of using larger page sizes in a virtual memory system, several important metrics are affected, including TLB hit rate, internal fragmentation, and the size of page tables. Here's how changes in page size impact each of these:
User
Match the memory hierarchy tier to access latencies. [Choose]= 1ns/10ns/100ns/100us
Registers
[ Choose ]
Cache
[ Choose ]
Main memory
[ Choose ]
Storage disk
[ Choose ]
Assistant
In the memory hierarchy of a computer system, different types of memory storage have different access times. Here we will match each tier in the memory hierarchy to the provided approximate access latitudes:
Registers:
Access time: 1ns
User
Demand paging has (i) performance and (ii) memory utilization whereas prepaging has (iii) performance and (iv) memory utilization. [Select]=lower/higher
(i) =
[ Select ]
(ii) =
[ Select ]
(iii) =
[ Select ]
(iv) =
[ Select ]
Assistant
Understanding the trade-offs between demand paging and prepaging in performance and memory utilization is key to selecting the correct paging strategy for various computing environments. Here's a breakdown:
Demand Paging:
Performance: Generally results in lower performance when compared to prepaging, primarily because it leads to page faults that halt process execution until the needed page is loaded into memory. This on-demand logic can cause latency due to frequent access to slower storage.
User
With clock algorithm, (i) sets the used/referenced bit and (ii) clears the used/referenced bit per page. i = OS/HW ii=OS/HW
Assistant
The clock algorithm, also known as the Second Chance replacement algorithm, is a form of page replacement algorithm used in managing memory in operating systems. It uses a circular list and a pointer to mimic a clock hand to determine which pages in memory to replace when a page fault occurs. Each page has an associated "used" or "referenced" bit, which plays a crucial role in this algorithm.
Here's how the responsibilities are typically divided between the hardware (HW) and the operating system (OS) in managing these bits:
i = Sets the used/referenced bit:
User
calculate the number of times "Hello" is printed:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]) {
fork();
fork();
fork();
printf("Hello\n");
return 0;
}
Assistant
In the given C program with multiple calls to the fork() function, each process created by fork() will itself also fork new processes. Here's a breakdown of how the number of processes increases with each call to fork() and how this affects the number of times "Hello" is printed:
First Call to fork():
This creates one additional process. There are now two processes: the original process (let's call it A), and the new child process created by the first fork() (call it B).
Second Call to :
User
Job Name Arrival time Runtime:
A 0 5
B ~0 5
C ~0 5
For the given job list, what is the average turnaround time with FIFO/FCFS scheduler? Round your answer to 2 digits after decimal.
Answer =
Assistant
To calculate the average turnaround time for the FIFO (First-In, First-Out) or FCFS (First-Come, First-Served) scheduling, we need to determine the completion time for each job and then find the turnaround time for each. The turnaround time for each job is calculated as the difference between the job's completion time and its arrival time.
Given the arrival pattern and runtime for each job (assuming ~0 for job B and C means the same as 0 like job A):
Job A: Arrival time = 0, Runtime = 5
Job B: Arrival time = 0, Runtime = 5
Job C: Arrival time = 0, Runtime = 5
Scheduling with FIFO/FCFS Algorithm:
Job A starts at time 0 (its arrival time). It runs for 5 units, so it finishes at time 5.
User
A 0 30
B 10 5
C ~10 5
For the STCF (Shortest Time-to-Completion First) scheduling policy, what is the average turnaround time? "~" indicates just after the time. Round your answer to 2 digits after decimal.
Assistant
To calculate the average turnaround time under the Shortest Time-to-Completion First (STCF) scheduling policy (also known as Shortest Remaining Time First, SRTF), we need to consider the order in which the jobs are executed based on their remaining time until they're completed. This policy is a preemptive version of Shortest Job First scheduling.
Base Addresses Assigned: Process P1 starts at base address 0x2000, and Process P2 starts at base address 0x6000.
Protection Mechanisms: Without a bounds register or another form of memory protection mechanism (such as paging with proper access controls or segmentation with limit checking), there is no system-enforced barrier that prevents one process from accessing the memory space of another.
Memory Access: Since there is no mechanism to prevent accessing memory beyond the range allocated to a process (like a bounds register would), it is technically possible for process P1 to access the memory of process P2 if it references an address calculated from its base that reaches into P2's space. For instance, if P1 calculates an address that effectively surpasses its intended limit (implied, not enforced), reaching into the address space starting from 0x6000 (base of P2), nothing in the system as described would prevent this access. This could occur through improper address calculation or programming errors such as buffer overflows.
In conclusion, on a system equipped only with base registers and without bounds registers or other protective mechanisms, there is a potential for process P1 to inadvertently or maliciously access the memory of process P2. This represents a significant security and stability risk, emphasizing the importance of employing comprehensive memory management and protection schemes in operating systems to ensure safe and stable operations across different processes and applications.
Security and Stability Concerns: Systems only employing a base register and no bounds checking are vulnerable to errors or malicious attacks that involve accessing or modifying the memory of other processes. Such access can lead to data corruption, unintended behavior, or security compromises.
Given this setup, while it's not intended by design, the lack of strict memory access controls (like those provided by a bounds register or more sophisticated memory management techniques) makes it plausible for P2 to access P1’s memory under erroneous or maliciously crafted conditions. This highlights the essential role of proper memory management mechanisms in modern computing systems to safeguard process isolation and system integrity.
Base Register Function:
The base register is primarily used to set the initial address from which each process can operate. P1 has its base at 0x2000, and P2 has its base at 0x6000.
Potential Overlap and Access:
Suppose there are no bounds registers or other memory protection schemes (like paging or segmentation with limits):
P1 Accesses start from 0x2000 upwards.
P2 Accesses start from 0x6000 upwards.
Without a bounds register or equivalent mechanism, it's assumed the system does not enforce any strict boundaries regarding how far a process can access memory beyond its base. Therefore, theoretically, P2 could access P1's memory by addressing memory below its base (0x6000) if the addressing is calculated in such a manner that it references addresses in P1’s range (0x2000 to somewhere below 0x6000). This could occur under specific circumstances, such as:
Underflow Address Calculation: Where an integer underflow or similar incorrect calculation results in a memory reference below the base of P2, potentially overlapping with P1’s memory range.
Programming Errors or Malicious Intent: Code in P2 designed to access arbitrary memory locations by manipulating pointers or offsets deliberately to reference P1's memory space.
Vulnerabilities and Security Issues:
The lack of a bounds register implies significant security and stability issues:
Security Risks: Processes can potentially read or write to the memory of other processes, leading to information leaks, data corruption, or deliberate exploitation.
System Stability: Erroneous memory accesses can lead to unpredictable system behavior including crashes.
Conclusion:
In the described configuration, yes, P2 can potentially access P1's memory if addresses are manipulated to fall within P1's memory range. This assumption heavily depends on the lack of additional protective mechanisms and represents a fundamental vulnerability in such a rudimentarily designed system. Proper protection would ideally involve bounds checking, use of segments with limits, or a more sophisticated form of memory management such as paging with access controls.
To determine how many memory accesses occur in a system using pure segmentation during a store instruction, you need to first understand how segmentation generally works and what steps are involved in accessing memory in such a system.
Segmentation Background
In a pure segmented memory system:
Each segment in memory has a corresponding segment descriptor that typically includes the base address of the segment and the segment's length or limit.
Segments are often used to separate different types of data (e.g., code, stack, heap) or different programs/modules.
Fetch and Execute of a Store Instruction
When an instruction is fetched and executed that specifically performs a store from a register to a memory address, the following steps occur, specifically in a typical segmented memory model:
Fetch the Instruction:
The Processor needs to fetch the instruction from the memory. This involves accessing the segment where the code (instruction) is located. Let's denote this as the code segment.
The memory access to fetch the instruction itself counts as one memory access.
Resolve the Target Memory Address:
Once the instruction is fetched and identified as a store instruction, the processor then needs to compute and resolve the effective memory address to which data will be stored. This may involve adding any specified offsets to a base address in the instruction.
In a segmented model, this usually involves referencing another segment (often a data segment or other) to determine where the data should be stored. This segment lookup might need to access the segment descriptor to verify the address and to ensure it does not exceed the segment boundary (limit checking for protection). However, this is more about checking and less about an additional memory access unless the system specifically needs to fetch segment details from memory.
Perform the Data Store:
Once the effective address (within its segment) is computed and validated against the segment's limit, the actual data stored in the register is written to this resolved memory location.
This operation itself counts as another memory access.
Total Memory Accesses
First Memory Access: Fetching the instruction from the code segment.
Second Memory Access: Writing the data from the register to the resolved and valid memory location in the relevant data segment.
Thus, for a simple store operation, two memory accesses typically occur: one to fetch the instruction and another to store data into the target memory location.
Other processes, such as segment validation or limit checks, even though critical for memory protection in segmentation, do not necessarily result in additional memory accesses unless segment details are not readily available in registers or cache and must be fetched separately from memory.
Step-by-Step Process:
Fetching the Instruction:
The processor must first retrieve the instruction from memory. This is performed by accessing the code segment where the instruction resides. This part consumes one memory access.
Calculating the Target Address:
Once the instruction is fetched, the processor interprets the instruction to determine the target memory address for storing the data. This step often includes combining an offset (provided in the instruction) with a base address (from the segment register).
Verifying Address Validity:
In a segmented system, each segment has limits (start and end addresses). The processor needs to validate that the calculated memory address falls within the allowable range of the target segment to ensure that the store operation does not violate memory protection policies. This verification step itself does not directly result in a memory access, but the segment's base address and limit might be fetched from memory if not cached, depending on the specifics of the architecture.
Storing the Data:
Finally, after the address is computed and verified, the processor will store the data from the register at the calculated memory address in the designated segment. This represents another memory access.
Analysis:
In the absence of more complex memory management hardware like Paging or Translation Lookaside Buffers (TLBs), the primary memory accesses explicitly needed are:
One access to fetch the instruction from the memory.
Another access to actually write the data to memory.
In summary, assuming typical operations and that segment bounds are stored in registers quickly accessible by the processor (minimizing the need to fetch these from memory repeatedly), a store instruction in a pure segmentation environment typically requires two explicit memory accesses: one for fetching the instruction and one for writing the data to memory. Additional validation of segment limits would be handled by the system but might not necessarily translate into further memory accesses unless there's a need to fetch segment metadata from memory during the operation.
When discussing the task of reading data from a register, particularly within the context of CPU operations, it's important to clarify the context to ensure accurate information. Register accesses within the CPU datapath refer to the process where the CPU reads data from its internal registers, which are small, fast storage locations directly within the CPU.
Context: CPU Operations
For operations that simply involve reading data from a register (i.e., internal CPU registers), it's crucial to note:
No Memory Access Required: Reading data from a register does not involve accessing the main memory. Registers are part of the CPU's internal architecture, designed for high-speed data access and manipulation. They are used for intermediate calculations, storing temporary data, and managing instruction-specific data.
Procedure for CPU Register Operations:
Accessing the Register Content:
When an instruction that requires reading from a register is executed by the CPU, the processor directly accesses the content of the specified register. Since these registers are part of the processor's internal memory, accessing them is extremely fast and does not involve memory access delays associated with RAM.
Usage of Register Content:
Once the data is read from the register, it can be used as part of an arithmetic operation, logic operation, or any other instruction that requires this data.
Example in CPU Instruction Execution:
For instance, consider an assembly instruction that adds two numbers from registers and stores the result in another register, something like:
ADD R1, R2, R3 (where R1 = R2 + R3)
Here, the CPU reads the values from registers R2 and R3, adds them, and stores the result in R1. All these operations happen internally within the CPU, and there’s no need for main memory access.
Summary:
To summarize, reading data from a CPU register:
Does not involve main memory access.
Is limited to internal CPU operations.
Is a fundamental part of virtually all CPU instructions that operate directly on data.
This operational characteristic is crucial for ensuring the high-speed execution of programs since accessing main memory (which involves considerably slower read/write operations compared to register access) would significantly slow down the processor for every operation needing data manipulation. Registers serve the purpose of providing rapid access to frequently used data and instructions without the bottleneck of external memory traffic.
In the provided code snippet, temporal locality refers to the degree to which the same memory locations are accessed repeatedly within short periods of time. Let’s explore how changes in the value of N will influence the temporal locality in the execution of this loop:
int sum = 0;
srand(8196);
for (int i = 0; i < 10000; i++) sum += arr[rand() % N];
This code initializes sum to zero and uses a loop to iterate 10,000 times, summing values from array arr[] indexed by a random number modulated by N. The effect of varying N, the divisor for the rand() function's result, affects which indices are likely to be hit and how frequently.
Effects of Varying N:
Lower Values of N:
When N is small, rand() % N produces a smaller range of index values. Thus, any specific index within this range is more likely to be accessed multiple times throughout the loop. This increases temporal locality since the same indices (and thus the same memory locations) are likely to be accessed repeatedly within short intervals.
Higher Values of N:
As N increases, rand() % N starts producing a wider range of values. Consequently, the likelihood of accessing any individual index multiple times diminishes because the accesses spread over a broader spectrum of arr[]. This reduces temporal locality since any specific memory location is less likely to be accessed repeatedly within short time frames.
Illustration:
Temporal Locality with Small N: Imagine N is 10 in a scenario where arr has space for at least 10 elements; the indexes accessed can only be 0 through 9. In 10,000 iterations with only 10 different possible accessed indexes, each index will likely be accessed around 1,000 times during the loop's execution, demonstrating high temporal locality.
Temporal Locality with Large N: Now assume N is 1,000 for an array with at least that many elements. Here, the possible accessed indexes range from 0 to 999. Given the higher distribution range, any particular index would statistically surface fewer times during the 10,000 iterations, suggesting a lower degree of temporal locality as the space between accesses to the same specific memory location generally increases.
Conclusion:
The temporal locality of this process decreases as the value of N increases. For smaller values of N, accesses are more condensed within a limited scope of memory locations, enhancing the chance of re-accessing the same locations within shorter intervals. For larger values of N, the wider span of memory locations accessed reduces the chance of frequent re-accesses to the same memory areas, thereby decreasing temporal cc.
TLB Hit Rate:
Effect: [Increase]
Explanation: The Translation Lookaside Buffer (TLB) stores recent translations of virtual page numbers to physical page numbers. When the size of each page is increased, fewer pages are needed to cover the same memory space. Consequently, a single TLB entry can now cover a larger portion of the memory, potentially increasing the likelihood of TLB hits. This reduces the number of accesses to the page table, as more memory accesses can be resolved directly from the TLB.
Internal Fragmentation:
Effect: [Increase]
Explanation: Internal fragmentation refers to the wasted space within an allocated memory region due to the granularity of allocations. With larger page sizes, there's often more unused space at the end of each page because the allocations are not always a perfect multiple of the page size. For instance, if a program needs 1.1 pages of memory, two full pages must be allocated with larger pages, significantly increasing waste compared to a scenario with smaller pages where less total space might be wasted.
Size of Page Tables:
Effect: [Decrease]
Explanation: Page tables map virtual addresses to physical addresses. With larger page sizes, the total number of pages required to map the entire virtual address space decreases since each page now covers more physical memory. Consequently, the page table, which maintains a record per page, can be smaller as there are fewer entries to maintain. This helps in reducing the memory requirement for storing the page table itself.
In summary, increasing the page size in a virtual memory system tends to increase TLB hit rates and internal fragmentation but decrease the size of page tables. Each of these changes has implications for system performance and memory efficiency, highlighting the trade-offs involved in choosing an appropriate page size for specific hardware and software configurations.
Explanation: Registers are the fastest type of memory access available in a computer system. They are located directly within the CPU and are used to hold data that the processor needs immediate access to while performing operations.
Cache:
Access time: 10ns
Explanation: Cache memory serves as an intermediary between the ultra-fast registers and the slower main memory. Caches like L1, L2, and L3 have progressively slower access times, with L1 being the fastest. An overall approximation can be set around 10ns, relatively faster than main memory and much slower than CPU registers.
Main Memory (RAM):
Access time: 100ns
Explanation: Main memory, also known as RAM, is slower than cache and registers. It is used to store data that needs to be frequently accessed by the CPU. Although slower, it provides a robust storage capacity compared to cache and registers and serves as the fundamental 'working memory' for programs and the operating system.
Storage Disk (HDDs for example):
Access time: 100us (microseconds)
Explanation: Storage disks such as hard drives have the slowest access time in the typical memory hierarchy. They provide vast storage capacity but are mechanical in nature (in the case of traditional HDDs), which significantly slows down their ability to access data compared to electronic storage technologies like SSDs. Nonetheless, even faster storage disks like SSDs, while much quicker than HDDs, are still slower in access times compared to RAM, cache, or registers, with access times typically in the range of microseconds when compared to other memory types.
Assigning these approximate latencies helps understand the trade-offs between memory types in terms of speed, capacity, and cost. It also highlights why computer architectures are designed with multiple layers of memory to optimize performance and cost.
Memory Utilization: Typically results in higher memory utilization efficiency. Since pages are only loaded when they are needed, memory is not wasted on pages that are not accessed, leading to better overall usage of the available memory.
Prepaging:
Performance: Generally viewed as having higher performance compared to demand paging, as it attempts to anticipate which pages will be needed and loads them into memory before they are actually accessed, reducing the frequency of page faults.
Memory Utilization: Typically results in lower memory utilization. This is because prepaging may load pages that may not be actually used, thus using up more memory space unnecessarily and potentially reducing the space available for other processes or data that might be actively needed.
To summarize:
Demand paging may suffer from lower performance due to page faults but offers higher memory utilization by loading only necessary pages.
Prepaging can offer better performance by minimizing page faults but might waste memory space due to less accurate prediction of needed pages, leading to lower memory utilization.
Both techniques present strengths and weaknesses that need to be balanced based on the specific requirements and behavior of the application or system being used.
OS/HW: HW
Explanation: Hardware typically sets the used/referenced bit automatically whenever a page is accessed, either for reading or writing. This action occurs at the hardware level as part of the memory access operations executed by the processor and the memory management unit (MMU).
ii = Clears the used/referenced bit per page:
OS/HW: OS
Explanation: The operating system is responsible for clearing the used/referenced bits periodically. In the case of the clock algorithm, the OS clears these bits as it scans through the "circular list" of pages, essentially giving each page a "second chance" before deciding to evict it. When the "clock hand" points to a page, if the reference bit is set, the OS clears it and moves to the next page. If it encounters a page where the bit is already cleared, it might choose to replace this page under the assumption it has not been used recently.
In summary:
Sets the used/referenced bit (i) = HW
Clears the used/referenced bit (ii) = OS
This division of tasks helps leverage both the hardware capabilities to quickly manage frequent memory accesses and the more complex logic of the OS to perform periodic maintenance and management based on memory usage patterns.
fork()
Both existing processes (A and B) each create a new child process.
Process A creates a child process (call it C).
Process B creates a child process (call it D).
Now, there are four processes in total: A, B, C, and D.
Third Call to fork():
Every one of the four existing processes creates a new child process.
Process A creates a new child (call it E).
Process B creates a new child (call it F).
Process C creates a new child (call it G).
Process D creates a new child (call it H).
We now have a total of eight processes: A, B, C, D, E, F, G, H.
Each of these eight processes now executes the printf("Hello\n"); statement. Therefore, the string "Hello" is printed 8 times.
Explanation of Growth:
Each call to fork() duplicates the number of existing processes. If n is the number of times fork() is called, then the processes created are (2^n). For the given code:
After 1st fork(): (2^1 = 2) processes
After 2nd fork(): (2^2 = 4) processes
After 3rd fork(): (2^3 = 8) processes
Each process runs the same code including the printf statement, leading to "Hello" being printed 8 times.
Turnaround time for Job A = Completion Time - Arrival Time = 5 - 0 = 5.
Job B can start only after Job A finishes, which is at time 5. Job B also runs for 5 units, so it finishes at time 10.
Turnaround time for Job B = Completion Time - Arrival Time = 10 - 0 = 10.
Job C starts after Job B finishes, thus beginning at time 10. Running for 5 units, it completes at time 15.
Turnaround time for Job C = Completion Time - Arrival Time = 15 - 0 = 15.
Calculating Average Turnaround Time:
Turnaround Time for A = 5
Turnaround Time for B = 10
Turnaround Time for C = 15
The average turnaround time can be calculated by adding the turnaround times for each of the jobs and then dividing by the number of jobs:
Answer: The average turnaround time with FIFO/FCFS scheduler is ( \textbf{10.00 } ).
Given the jobs and their characteristics:
Job A: Arrival time = 0, Runtime = 30
Job B: Arrival time = 10, Runtime = 5
Job C: Arrival time = just after 10, Runtime = 5 (assuming ~10 means 10 + a very small time)
Detailed Execution:
Job A starts at time 0.
When Job B arrives at time 10, Job A has been running for 10 units, so it still has 20 units left. Since Job B's runtime (5 units) is less than the remaining time of Job A, Job B preempts Job A and starts executing at time 10.
Job C arrives just after time 10, but Job B is already running. Since the runtime of Job C is the same as Job B's remaining runtime and STCF usually keeps the current running job unless a shorter job arrives, hence Job B will continue to run. Job C will wait until Job B is complete.
Job B completes at time 15. Turnaround time for Job B = Completion Time - Arrival Time = 15 - 10 = 5 units.
Next, Job C will run for 5 units from time 15 to time 20 since it has the shortest remaining runtime (5 units) compared to the remaining time of Job A (20 units left from time 10, paused). Turnaround time for Job C = Completion Time - Arrival Time = 20 - 10 = 10 units (noting that it technically arrived just past 10, but for calculation simplicity, we consider it at 10).
Finally, Job A resumes after both Job B and Job C have completed, running from time 20 until time 50 (30 units total minus the 10 initially run). Turnaround time for Job A = Completion Time - Arrival Time = 50 - 0 = 50 units.