Skip to content

Module 4: Device Manager

Handles Terminal I/O and Disk operations (Load and Store).

Function Number Function Name Arguments Return Value
DISK_STORE = 1 Disk Store PID, Page Number, Block Number NIL
DISK_LOAD = 2 Disk Load PID, Page Number, Block Number NIL
TERMINAL_WRITE = 3 Terminal Write PID, Word NIL
TERMINAL_READ = 4 Terminal Read PID, Address NIL

Disk Store

Description : Stores the contents of the page into the disk block. A valid PID as input is assumed.


Acquire the lock on the disk device by calling the Acquire_Disk() function
in the Resource Manager module;

Set the LOAD/STORE BIT, PAGE NUMBER and BLOCK NUMBER in the Disk Status Table.

Use the store statement to store the memory page to disk;

Set the state as (WAIT_DISK, - );

Call the switch_context() function from the Scheduler Module.

return;

Called by Shutdown, Buffer Read and Buffer Write.

Disk Load

Description : Loads the contents of the disk block to the page. A valid PID as input is assumed.


Acquire the lock on the disk device by calling the Acquire_Disk() function
in the Resource Manager module;

Reset the LOAD/STORE BIT, set PAGE NUMBER and BLOCK NUMBER in the Disk Status Table.

Use the load statement to load the disk block to memory;

Set the state as (WAIT_DISK, - );

Call the switch_context() function from the Scheduler Module.

return;

Called by the Buffer Read, Buffer Write functions, exec system call (to load the first code page) and the exception handler (demand paging).

Note: The bootstrap code must use loadi statement and not this function.

Terminal Write

Description : Reads a word from the Memory address provided to the terminal. Assumes a valid PID is given.


    Acquire the lock on the terminal device by calling the Acquire_Terminal() function
    in the Resource Manager module;

    Use the print statement to print the contents of the word
    to the terminal;

    Release the lock on the terminal device by calling the Release_Terminal() function
    in the Resource Manager module;

    return;

Called by the Write system call.

Terminal Read

Description : Reads a word from the terminal and stores it to the memory address provided. Assumes a valid PID is given.


Acquire the lock on the disk device by calling the Acquire_Terminal() function
in the Resource Manager module;

Use the read statement to read the word from the terminal;

Set the state as (WAIT_TERMINAL, - );

Call the switch_context() function from the Scheduler Module.

Copy the word from the Input Buffer of the Process Table of the process corresponding to PID
to the memory address provided.

return;

Called by the Read system call.

Note

The Terminal Interrupt Handler will transfer the contents of the input port P0 to the Input Buffer of the process.

Back to top