2016 OS Project 2

- Synchronous Virtual Device


  • Learn the implementation of memory pages and different serial communication mechanisms, and compare the performance.

Due Time

  • 2016/06/14 23:59:59

Demo Time

Please register your demo timehere.


Internet of things (IoT) is a popular topic in recent years. It is the network of physical objects, such as devices, vehicles, buildings and other things. Through the network, we can integrate the data collected by these objects, to reach an improvement in traffic, logistics, medicine, geriatrics, crime prevention and many other areas, which presents a Smart City Framework. Performance is one of the most consideration in system, especially in real-time system. However, these “smart” objects, usually based on an embedded system, which has less resource to calculate large data. Therefore, we could transmit these data to servers for analyzing, and we would have to decide which I/O should we implement in the system to get better performance. In this project, we would like to study synchronization in communication through writing device drivers, and compare the performance of primitive (read/write) I/O and memory-mapped I/O.


Given partial sample codes of virtual IoT which can transmit the data through kernel socket (TCP) with synchronous file I/O, you are asked to compare the performance with another approach through memory-mapped I/O, using functions like mmap.

We simulate an application of IoT in a master-slave model. The slave device establishes a TCP connection to the master with the IP address set by the user program through ioctl, which present the server collecting the data from specific device. In contrast, the master device listens on a specific TCP port when the module is loaded into the kernel.

There is a user program in each side, one for accessing the slave device (slave side) and the other for accessing the master device (master side). For the slave-side program, it first uses ioctl to set the IP address of the master. It then receives the data from the slave device and writes all of them to the output file by the specified method. You should display the whole content of page descriptors of the mapped memory region in hexadecimal on the console after all data have been written. Similarly, the master-side program will read the input file by the specified method and send the data to the master device. There is a kernel program in each side, one for receive the data from master device, and transmit to user program (slave side), one for receive the data from user program, and send to master device (master side).

Once the transmission has completed, the programs will show the total transmission time, measured from when the device is opened until the device is closed, and the size of the transferred file in both computers. All the parameters will be passed to programs through the standard input.

For bonus, you should transmit the data through kernel socket with asynchronous I/O, and compare the performance.

Program Input

  • The programs will get the input parameters from the standard input.
    • For the slave-side program
      • L - location to place the received file.
      • M - method to write the file and the device. fcntl for file I/O and mmap for memory-mapped I/O.
      • IP - IP address of the master.
    • For the master-side program
      • L - location of target file.
      • M - method to read the target file and the device. fcntl for file I/O and mmap for memory-mapped I/O.

For example, parameters for the slave-side program using file I/O might look like this:

./slave received_file fcntl

Parameters for the master-side program using memory-mapped I/O might look like this:

./master target_file mmap

Program Output

  • Once the file transmitted, show the total transmission time and File size.
    • Time Size
      • Time - the transmission time
      • Size - the size of the transmitted data

Sample output from the command

Transmission time: xx ms, File size: xxx bytes

Sample output for the page descriptors


Platform A real or virtualized PC or NB.
OS Linux
Programming Language C
Machine try to find one yourself


Completeness of functionality 50%
Stability 25%
Report 20%
Coding style 5%
Bonus 10%
  • Late penalty is 10% per day. E.g. if 2 days late and with grade 90, the final grade will be 90 * 90% * 90% = 72.9
  • You will not get any points if you do not demo your project to the TAs.
  • Please also describe your roles in your project (report).

Handing in

  • Turn in a report (no more than 5 pages) including:
    1. The results
    2. The comparison the performance between file I/O and memory-mapped I/O, and explain why.
    3. The comparison the performance between synchronous I/O and asynchronous I/O, and explain why.
  • Make your source codes self-documented.
  • Upload your source codes and executable file, including Makefile, *.c, *.h, to FTP server.
    • For the source codes in kernel, you only need to upload the modified files.
  • Please put all files in a compressed file named GroupID_REV#.suffix, e.g 23_0.zip for the first upload of group 23.
  • Host:, Port: 21, User: os2015 Password: os2015HomeWork, Directory: project2
  • Please prepare your own (remote) machine for demo if necessary.


playground/playground.txt · 上一次變更: 2016/05/11 08:56 由 jason
CC Attribution-Noncommercial-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0