ClickHouse - 你没有见过的列存储| 青训营笔记

134 阅读2分钟

这是我参与「第五届青训营 」笔记创作活动的第16天

C12 Mass Storage Structure

Platter盘片、track、sector(扇区)、多个扇区(block)、同一个位置磁道位柱面(cylinder)

what are seek time,rotional latency,transfer time?

Read/Write data is a three-stage process: Seek time: Rotational latency: Transfer time: image.png

How to schedule disk I/O requests?

FCFS

SSTF

SCAN

:计算磁头移动的距离可以不用逐个计算。 Two I/O Methods: Synchronous- process suspended until I/O completed Asynchronous- process runs while I/O executes

Polling

the host repeatedly reads the busy bit until that bit become clear

Interrupt-driven I.O

image.png DMA-(Direct Memory Accesss直接内存访问) Bypasses CPU to transfer data directly between I/O device and memory. spoolig(Simulaneous periheral operation on line)(假脱机)

16. Consider a system running ten I/O-bound tasks and one CPU-bound task. Assume that the I/O-bound tasks issue an I/O operation once for every millisecond of CPU computing and that each I/O operation takes 10 milliseconds to complete. Also assume that the context-switching overhead is 0.1 millisecond and that all processes are longrunning tasks. Describe the CPU utilization for a round-robin scheduler when: a. The time quantum is 1 millisecond b. The time quantum is 10 milliseconds

Answer:

a. The time quantum is 1millisecond:

Irrespective of which process is scheduled, the scheduler incurs a 0.1 millisecond context-switching cost for every context-switch.This results in a cPU utilization of 1/1.1*100 =91%.

b. The time quantum is 10 milliseconds:

The I/0-bound tasks incur a context switch after using up only 1 millisecond of the time quantum. The time required to cycle through all the processes is therefore 101.1 +10.1(as each I/O-bound task executes for 1 millisecond and then incur the context switch task, whereas the CPU-bound task executes for 10 milliseconds before incurring a context switch). The CPU utilization is therefore 20/21.1100= 94% 4. Explain the difference between the first readers–writers problem and the second readers–-writers problem. Ans: The first readers–writers problem requires that no reader will be kept waiting unless a writer has already obtained permission to use the shared database; whereas the second readers–writers problem requires that once a writer is ready, that writer performs its write as soon as possible.

  1. Three processes P1, P2, P3 cooperate to print files. P1 reads one record from disk to buffer1, P2 copy the record from buffer1 to buffer2, and P3 print the record in buffer2. If the sizes of buffer and record are same, please write the pseudocode to print files correctly using semaphores.