• Tidak ada hasil yang ditemukan

Operating Systems Assignment 3 – Hard

N/A
N/A
Protected

Academic year: 2025

Membagikan "Operating Systems Assignment 3 – Hard"

Copied!
3
0
0

Teks penuh

(1)

Operating Systems Assignment 3 – Hard

Instructions:

1. The assignment has to be done individually.

2. You can use Piazza for any queries related to the assignment and avoid asking queries on the last day.

1 Character Device Driver

Device drivers are built as loadable kernel modules (LKMs), which can be added to or removed from the kernel at runtime. To uniquely identify a device, Linux assigns major and minor numbers to a device. Themajor number represents the device type and the minor number identifies the device. A device driver receives system calls from users and then appropriately manages the device (internally represented as a file). Hence, the device driver must implement the system calls specific to files: open, close, read, write, lseek, mmap, etc. These operations are described in the fields of the struct file operations structure.

1.1 Problem Statement

Design and implement a character device driver for a virtual LIFO (last in, first out) device (see link), whose size is practically unbounded (can be quite large, let’s say limited to 1 MB). We will give it smaller inputs as test cases. You must create two virtual LIFO devices that use the same device driver. One of the devices must be read-only, while the other must be write-only. The characters written to the write-only device can be read only from the read-only LIFO device. The first character read from the read-only LIFO device corresponds to the last character written to the write-only LIFO device. Reading from an empty LIFO device should return an EOF. Otherwise, the process calling the read operation must be blocked, and the process must be woken up once characters are available to be read.

1

(2)

The pseudocode for the reader is shown below:

int m a i n (int argc , c h a r * a r g v []) {

c h a r d e v i c e [ M A X _ B U F _ S I Z E ];

c h a r u s e r _ m s g [ M A X _ B U F _ S I Z E ];

s t r c p y ( device , a r g v [ 1 ] ) ; fd = o p e n ( device , O _ R D O N L Y ) ;

m e m s e t ( u s e r _ m s g , 0 , s i z e o f( u s e r _ m s g ) ) ; ret = r e a d ( fd , u s e r _ m s g , M A X _ B U F _ S I Z E ) ; c l o s e ( fd ) ;

}

The pseudocode for the writer is shown below:

int m a i n (int argc , c h a r * a r g v []) {

c h a r d e v i c e [ M A X _ B U F _ S I Z E ];

c h a r u s e r _ m s g [ M A X _ B U F _ S I Z E ];

s t r c p y ( device , a r g v [ 1 ] ) ; s t r c p y ( u s e r _ m s g , a r g v [ 2 ] ) ; fd = o p e n ( device , O _ W R O N L Y ) ;

m e m s e t ( u s e r _ m s g , 0 , s i z e o f( u s e r _ m s g ) ) ;

ret = w r i t e ( fd , u s e r _ m s g , s t r l e n ( u s e r _ m s g ) ) ; c l o s e ( fd ) ;

}

2 Deliverable

1. The character device driver for a virtual LIFO device.

2. Test script that demonstrates the functionality of the driver.

3. Prepare a PDF file with the name A3 report.pdf that includes a descrip- tion of the driver’s functionality, a list of any issues encountered during development and testing.

3 Bonus

The bonus marks will be awarded based on the resilience of the device driver.

4 Submission Instruction

1. We will run MOSS on the submissions. Any cheating will result in a zero in the assignment, a penalty as per the course policy and possibly much stricter penalties (including a fail grade).

2

(3)

2. There will be a demo for the assignment in which you must demonstrate the functionality of the character device driver. This will be followed by a viva in which your general theoretical and practical understanding will be tested (in the context of the assignment). Note that regardless of the code that you submit, the viva performance is vitally important.

3. Create a zip file that contains the report, test script, and a folder that contains the character device driver files, and then name the zip file as, assignment3 hard < entryN umber > .zip. Submit this zip file to Moo- dle. Entry number format: 2020CSZ2445. Note that all English letters are in capitals.

3

Referensi

Dokumen terkait

The Pursuit of Happyness movie explain that the hard working that done by Chris Gardner as a major character in this movie, is used to show the struggle for successful, happiness,

The achievement and enhancement students’ mathematic h ard skills that acquire innovative teaching values and character nuances better than the math students hard skills

A user interface is the combination of hardware and software that helps people and computers communicate. DOS uses a command-line

Luckily, many of them are auxiliary files created by LATEX or BibTeX and which you don’t need to bother about: Bibliography.bib– this is an important file that contains all the

What is being provided: Your assignment packet contains code for the game server in python and client code for your player in python that: 1 interacts with the game server, 2 al- lows