File Operations

Two principal classes of file operations are considered:

Explicit File Access

Access to file content using explicit operations involves a buffer shared by the accessor and file provider. Two indexes or pointers within the buffer are employed, indicating the following:

data_start
the current position in the data available to read
data_end
the extent of the data available to read

Meanwhile, the writing of data causes the data_start pointer to advance, with the written data appearing behind the advancing pointer. If the pointer reaches the data_end pointer, it too advances ahead of written data.

Read Data

Initial state:

buffer     |--------|
data_start  |->
data_end    |->

After fs_read:

buffer     |=====---|
data_start  |->
data_end         |->

At end of data:

buffer     |=====---|
data_start       |->
data_end         |->

(A read attempt causes position change and return to initial state, followed by fs_read.)

Write Data

Initial state:

buffer     |--------|
data_start  |->
data_end    |->

After client write:

buffer     |***-----|
data_start     |->
data_end       |->

At end of buffer:

buffer     |********|
data_start          |->
data_end            |->

(Write causes fs_write, position change and return to initial state.)

After fs_read and consumption of some available data:

buffer     |======--|
data_start     |->
data_end          |->

Write after read:

buffer     |===***--|
data_start        |->
data_end          |->

(Read causes fs_write, position change and return to initial state.)

Memory-Mapped File Access

Access to file content through memory mapping involves the reservation of a virtual address region within which memory accesses cause the retrieval and potential modification of file data.