Programming Project #1: Real-Time Information Parsing 

Submit Assignment

  • Due 30 Nov by 23:59

 

  • Points 100

 

  • Submitting a file upload

 

  • Available 8 Nov at 0:00 - 21 Dec at 23:59 about 1 month

Project 1: Real-Time Information Parsing using C/C++ 

Total Marks: 100 (scaled to 15% of the total module)

 

Project Objectives

1.    To develop a working experience of structured C/C++ programming with libraries and project management, and

2.    To gain experience with real-time systems programming -- which is often essential for real-world embedded or high-performance applications.

 

The aim of this assignment is to write your own real-time parser reading a system file: “/proc/stat”, “/proc/meminfo” and “/proc/uptime”. Various pieces of information about operating system’s activity are available in these files, including CPU activity, number of cores available in the system, memory activity, up time and so on. All of the numbers reported in this file are aggregates since the system first booted. For a quick look, simply cat the files in repl shell (open a new repl c++ project, and try issuing the “cat /proc/stat” command in the shell).

The result of an example command is shown above. The detailed meaning of the different parameters in these real-time files can be found below:

1.    /proc/stat: https://tinyurl.com/7hbmb4p (Links to an external site.) (Section 1.8)

2.    /proc/meminfo: https://tinyurl.com/7hbmb4p (Links to an external site.) (Section 1.2)

3.    /proc/uptime: https://tinyurl.com/7hbmb4p (Links to an external site.) (Section 1.2)

 

Your program should have the following features:

1.    Make a parsing library for each real-time file. For example: hpp and stat.cpp for stat file parsing, meminfo.hpp, meminfo.cpp for meminfo file parsing and uptime.hpp and uptime.cpp for uptime file parsing. The parsing should include different file handles functions (open file and close file) and other information collation functions, such as getCPUActivity(…) and getFreeMemory(..), and getUpTime(..). You are encouraged to create your own namespace as well. [40 Marks]

2.    Read each line in these files as strings of characters and use string processing techniques to parse the lines (i.e. access and convert from string of characters to their respective types and so on). [25 Marks]

3.    All libraries should be included within cpp to gather the following real-time information:

1.    Activity (busy, idle, nice and system in %) profile for each CPU,

2.    Memory: total amount of RAM available, and how much of it is being used and not used. Plus how much of it is being used for buffering, caching and swapping.

3.    How much longer has the system been up and idle (in hours, minutes and seconds). Also research approximate idle and active power consumption for your system, and calculate how much energy had been effectively used in active state and how much of it has been used in idle state. Get some ideas about Intel processors here: http://tinyurl.com/y8uzuybd

4.    Generate an output screen that automatically refreshes every 500ms (see below):

---------------------------------------------------------------------------------------------

CPU Cores: 4

---------------------------------------------------------------------------------------------

CPU           busy                 nice                  system              idle

CPU0         1.9%                 0.0%                 0.8%                 97.3%

CPU1         1.4%                 0.0%                 0.4%                 98.2%

CPU2         2.1%                 0.0%                 0.6%                 97.3%

CPU3         1.6%                 0.0%                 0.6%                 97.8%

---------------------------------------------------------------------------------------------

Page in/out ratio: 0.403753              Swap in/out ratio: 0.404355

Interrupts serviced: 3.61 billions       Context switch counts: 2.65 billions

---------------------------------------------------------------------------------------------

MEMORY            Total: 4295MB  

                              Free: 4133MB

                              Cached: 2315MB

                              Buffered: 59MB

---------------------------------------------------------------------------------------------

SYSTEM                 UP for 112 hours 34 minutes and 56 seconds

                              IDLE for 65 hours 23 minutes and 22 seconds

---------------------------------------------------------------------------------------------

ENERGY

                              In Active State: 14.47 MJoules

                              In Idle State: 1.47 MJoules

---------------------------------------------------------------------------------------------

[Calculation/Coding: 30 and Display: 25 Marks]

 

Note that the presentation will need to be similar (for example 1-digit precision after decimal point for the time stats and in %, 2-digit precision for the numbers of interrupts and context switches with billions to round up to an approximate number). Some calculations based on the stats file are shown in the stats-arithmetic.xlsx file attached.

Your program must update the stats real-time. For this you will need an outer loop to read the “/proc/file” (where the file is either statmeminfo or uptime) each time and carry out the necessary conversions, and parsing within the loop. After displaying the output in each instance, you should ask the system to delay the next reading and stats update by 500 milliseconds. An example of sleep based delay process is given in: http://linux.die.net/man/3/usleep

A C++ file streaming example with string tokenisation and refreshed reading is given for demonstration purposes only. See file_example.cpp.

4.    Write a Makefile to be able to pre-process, compile and link the project and generate the output binary. [10 marks]

 

Deliverables

You should submit a single archive (*.zip or *.tar archives only) with Makefile and the rest of the source code files consisting of the correct program. No report is necessary.

 

Marking & Rubric

This part of the module is assessed by 30% programming assessment. This assignment will constitute 15% of the total mark for the module. The marks’ distribution is already shown in the problem descriptions, totalling 100. The actual mark will be scaled to the module’s marks afterwards. See the Rubric below for detailed guidance:

 

Features

Marks

All basic requirements met, plus the program is working as expected (with comments put in the appropriate places) and the presentation is accurate. Also there are clear evidences of using advanced features for efficient program – such as modular programming with functions, error checking, data structures and pointers where necessary.

90-100%

All basic requirements met, plus the program is working as expected (with comments put in the appropriate places and accurate presentation). There are some evidences of organised programming with clear understanding of memory-efficient programming (e.g. using minimally allocated memory and clearing them when not necessary).

80-89%

Basic requirements met, the program does not have advanced features but it is performing correctly (and there are comments in appropriate places).

70-79%

Basic requirements are partially met, occasionally lacking appropriate data structure and coding formats/comments.

60-69%

Program is in working order, all components are designed per se, but the program clearly does not meet all basic requirements.

50-59%

Program is not working, the codes are inappropriately designed; there are minimum to acceptable evidences of understanding how C/C++ codes are written and organised.

10-49%

No show, no code or meaningless submission.

0-9%

 

PLAGIARISM

Plagiarism is strictly prohibited as it may result in serious penalties. There would be informal tutorial discussions on this assignment organised separately. The submission deadline is strictly 23:59 hours 30 Nov 2020, after which the submissions would be considered late and usual late submission rules would apply.

 

Feedback

After your assignment has been marked, feedback is provided as follows:

Canvas: Moderately detailed comments will be provided with high-level brackets of the Rubric provided above, when marking. On demand, more detailed feedback will be provided.