You are on page 1of 16

REAL TIME SYSTEMS (CT087-3-3)

UC3F1911CS(DA)

HANDOUT DATE: 20/11/2019

SUBMISSION DATE: 15/03/2020

LECTURER’S NAME: DR. IMRAN MEDI

STUDENT NAME: EMAAD MUSTAPHA PEERUN

STUDENT NUMBER: TP046492

Contents
1 ABSTRACT.............................................................................................................................3
2 INTRODUCTION....................................................................................................................4

3 LITERATURE REVIEW.........................................................................................................5

3.1 Key Real-time considerations...........................................................................................8

4 METHODOLOGY...................................................................................................................9

4.1 Analyzing CPU Usage for the Car Parking Simulation for JAVA.................................10

4.2 Analyzing Memory Usage of the Car Parking Simulation for JAVA............................12

4.3 Analyzing Memory Usage for the Car Parking Simulation for GO...............................13

5 Results and Discussions.........................................................................................................14

6 Conclusion..............................................................................................................................14

7 REFERENCES.......................................................................................................................15
1 ABSTRACT

This paper written to highlight the importance of parcel delivery systems and its important
features. The use of courier app system and it is programming is also mentioned. Parcel delivery
system is chosen as scenario for this assignment and its advantage, features and uses, which
develop by C# programming language. Furthermore, a literature review is included to provide
more insightful knowledge on delivery app systems.

2 INTRODUCTION
Parcel delivery is one of such industries that has also transformed due to the repercussions of on-
demand services. In times where online shopping and ecommerce are booming it, the need of the
hour to meet the challenges of instant deliveries with a robust courier delivery services and to do
that you would require an advanced parcel delivery application that consists of all the cutting-
edge features.

The concept of on-demand apps have redefined comfort and convenience for customers. An on-
demand delivery application has shown great potential in serving the customers across different
industry verticals including hospitality, healthcare, and e-Commerce. In the age of online
shopping and e-Commerce, courier services have a vital role to play to deliver products on time
at the customer’s doorstep.

3 LITERATURE REVIEW
Nowadays, most of the daily technology that we interact with depends on embedded micro-
processors. This has led to significant rise in real-time software. Over the last 20 years, real time
operating systems have experienced great evolvement leading to the development of thousands
of commercial products on the market. Real time operating system (RTOS) is described by (High
Integrity Systems, n.d) as a software component that allows quick switches between tasks
(threads) which in turns makes the user interpret it as multiple programs being executed at the
same time on a CPU. Others (NI.com, 2013) describes a RTOS as the main software that run
computer applications under specific deadlines and also providing adequate results. To sum up,
we can summarize the descriptions given above in a succinct way by stating that a Real Time
Operating System is simply an operating system which has very fast response while also dealing
with simultaneous tasks or commands to ensure that an appropriate response is given within a
specific period of time.

RTOS provides several important elements which differentiates it from a normal operating
system. They are:

 Concurrency
Concurrency in RTOS offers the ability for the system to execute multiple tasks
simultaneously or we can say concurrently. Furthermore, it also takes into consideration
memory management while also allowing switching between the tasks depending on
specific events and priorities.
 Pre-emption
Pre-emption offers the ability to the operating system to halt a task to give priority to a
more important task to be executed. Operating systems with many conditions beneficiate
from pre-emption since allows the functionality to prioritize specific tasks to ensure that
desired output is obtained in scheduled time.
 Synchronization
Synchronization allows the operating system to protect its shared resources. RTOS enable
the synchronization of tasks and messages to transfer and share specific data between its
tasks. (Design News,2016)

There are 2 main categories that real time operating systems can be classified into. They are
hard real-time systems and soft real-time systems. However, these 2 main categories can be
further sub-categorized into further categories which will be tabulated below along with their
characteristics.

HARD REAL-TIME SYSTEMS SOFT REAL-TIME SYSTEMS


Delay in response time leads to financial loss Delay in response time is acceptable but not
or loss of life. desired.
Cost associated is usually critical and Cost associated is usually abstract.
expensive.

Firm Real-Time Systems Weakly Hard Real-Time Systems


Job not finishing on time leads to obsolete Deadlines are usually met in probabilistic
computation. fashion.
Control usually lose its stability due to many
missed control cycles.
Example: EMI (Electro Magnetic
Interference)

(NICTA, 2008)
Example : Forecast System

Although real time operating systems may seem like the higher-end operating system, this is not
usually the case. RTOS has its advantages as well as its disadvantages which are discussed
below.

Advantages Disadvantages
Provides Priority Based Scheduling: Limited Tasks:
Through the use of “Scheduler”, RTOS Only a limited number of tasks can be run
allows the suspension of a task which can be simultaneously while focusing their
resumed afterwards through the lifecycle of concentration only on few applications to
the task. Tasks can be put to “sleep” and wait ensure errors are not encountered.
until resources are available.
Provides abstract timing information: Makes use of heavy system resources:
Through the use of API, a set of commands is System resources that are used are often
available to programmers which helps to inefficient and expensive.
alleviate the need to write codes from scratch.
It encourages better application codes to be
developed.
Comes with modularity: Uses complex Algorithms:
RTOSs are modular operating system which Complex Algorithms are used which leads to
separates the core from protocols and difficulty on developer’s side to perform
applications. This is crucial for efficient edits.
memory management of the system.
Performs Idle Processing: Empowers thread priority:
Background processing occurs in RTS and Thread priority leads to the system being less
ensures that CPU load measurement does not prone tasks switching.
affect the main processing system.

(GeeksforGeeks & UKDiss.com, n.d)


3.1 Key Real-time considerations

Latency

When analyzing run-time performance of a system, there are few metrics of kernel performance
that must be taken into consideration. One of the main metrics is latency. Latency can be
described as the time difference between which an interrupt is generared and an external
response is generated by the interrup handler. (Hambarde & Varma & Jha, 2014) In addition,
latency can also be referred to as ‘minimum response delay’. Latency can be split into two types
which are context switch time and scheduling overhead. Context switch latency is the time
between an event occuring and the switching of two different tasks under the operating systems.
Schedule latency is the maximum of the time for scheduling overhead and the time taken to save
and restore a thread context. (Walls, n.d)

Memory management

When it comes to memory management for RTOS, there are two types which are involved
namely stack and heap managements. Normally, an operating system tends to allocate a
minimum amount of physical memory to the various tasks to achieve small footprint. For
multitasking RTOS, every tasks need to be given a memory space to store their contexts to allow
context switching. This management process that occurs is named as stack management. After
initializing of the program, the rest of physical memory left is named as the heap which is used
for tasks. Upon completion, a task use up a memory block and is directed to the pool. Therefore,
when managing the heap memory, the process is referred to as heap management. (Renesas,
2010)

Timer management

In RTOS, the tasks are scheduled to be performed according to a time schedule. Therefore, time
delays and timeouts need to be recorded.RTOS provided timers that work in units of ticks and
also with calender date and time. This helps to identify whether tasks are being delayed or tasks
have not met their deadlines. ( Renesas, 2010)
4 METHODOLOGY
In order to evaluate, analyze and come up with proper conclusions to differentiate between the
two programming language used for this assignment (JAVA and C#), tests must be carried out
using appropriate tools. There are many types of tests that can be carried. However, we will be
focusing on analyzing the memory management, CPU usage and garbage collection. By
analyzing the memory heap management, we will be finding more about memory leaks which
might be present in the systems. CPU usage will give us a better insight on the time span
methods and threads are being executed. This approach was selected to ensure that the key real
time considerations are given proper focus. Henceforth, this will help to better evaluate and help
to fine tune the performance characteristics of both programming languages. The tools that will
be used for JAVA is the integrated NetBeans Profiler which generates the graphs interpreting the
CPU usage, Garbage Collection, Memory Usage. Hence, analysis can be conducted accordingly.
Furthermore, for C# using Visual Studio 2017. Visual studio performance and diagnostics option
helps to identify CPU and memory usage.
4.1 Analyzing CPU Usage for the ATM Transaction App Simulation for JAVA

Visual VM is used since it insight on the execution time the methods are taking on the CPU in
order to execute. Each individual method’s execution time is detailed accordingly. The execution
times and invocation count of each method is given which helps to measure and optimize the
performance of the system. From the diagram above we can conclude that the maximum CPU
time that was used to execute the application was only 8.7%.. It helps to test whether the system
experiences slow responses which helps to optimize algorithms to better fine tune the speed of
execution. (NetBeans, n.d) The diagram below gives an insight on the profiling data of methods
of all the classes.
From the profiling diagram, it states that there are 2 threads are being profiled since these are the
main threads that are used to build the ATM Transaction App. Furthermore, we can observe that
only Thread-6 and Thread-7 are being executed on the CPU. This further confirms the previous
statement. Expanding these threads, we have an overview of the methods executing time which
is being exerted on the CPU. There are 2 columns which are labelled as “Total Time” and “Total
Time (CPU)”. The total wall time for each time of the method is represented under the ‘Total
Time’ column. The wall time can be described as the time taken for outgoing calls, the time
taken to go throughout the method while also including wait and sleep time present in the
method. On the other hand, the total time taken for the CPU to execute the methods respectively
is shown under this column.

Moreover, the main method is also represented in this section showing the time taken for the
main method to be executed and the time taken for the CPU to execute the main method as
shown below
From the data collected, we can observe that the main method took 265ms to be executed
completely while it also took 82.5ms for the CPU to finish the execution of the main method.
The diagram below shows an overview of the method profiling mode.

4.2 Analyzing Memory Usage of the ATM Transaction for JAVA

At first glance, we can deduce that the Used Heap size is 23,020,016 Bytes which proves that
there is memory usage taking place from the heap size of 134,217,728 Bytes. Throughout the
garbage collection process, the heap size remains constant which indicates that there is no
memory leak taking place in the ATM Transaction App. However, the used heap size faces a
small increase gradually during the process.

To get a better understanding of the process going on, object profiling mode is used. It helps to
have an overview of the classes which are creating live objects and their respective live bytes
which is being used up.

From the diagram above, we can conclude that int[], char[],byte[] and java.lang.String classes
are the ones who are creating the most live objects which significant size in terms of Bytes. After
carrying out garbage collection, a small increase in the amount of objects created by int[],
char[],byte[] and java.lang.String classes is noticed. This indicates that the used heap size
experienced a small increase.
Heap dump can also be carried out to get a better understanding about how many objects are
being created and how much space they are occupying on the memory heap. From the diagram
above, we can deduce that the class char[] is creating most objects, 256,168 , of size 22,761,840
Bytes in the heap. The latter is followed by the class java.lang.Object[] which is creating 230,360
live objects of size 8,470,208 Bytes. These 2 classes are considered as the ones who are
consuming most memory in the heap.

4.3 Analyzing CPU and Memory Usage for the ATM Transaction App for C#

CPU Usage:

Memory Usages:
. From the diagram we can conclude that the maximum CPU time that was used to execute the
application was only 79.2% and Maximum memory used 7.3 MB.

5 Results and Discussions


Java Output:

C# output:
From the results obtained, it is clear that JAVA is a preferred language compared to C# for the
development of Real Time Systems. This is due to the fact that JAVA has proven to be a higher
and better level programming language compared to C#. JAVA is able to handle multithreading
very effectively and offers automatic garbage collection. Furthermore, JAVA offers the
functionalities such wait(), notify () and synchronize() which is really useful for multithreaded
applications. C# also handle multithreading and has to make use of Wait Groups or channels but
JAVA is better.

JAVA offers its user the opportunity to not pay too much attention about garbage collection
since it is carried out automatically and unused objects are removed accordingly in the heap
which is important when it comes to memory leak. JAVA also favors maximum CPU usage
when it comes to multithreading while sharing computing resources using the synchronize
function. Furthermore, when it comes to analysis part for C#, very limited resources is available.
The use of diagnostics tools offers basic general overview results of memory and CPU activities
which lead to poor analysis and also to poor improvement in performance. For JAVA, results
obtained is clearly understandable and further analysis can be achieved through the evaluation of
the graphs.

6 Conclusion
Throughout this assignment, we have seen that real time systems have become an essential part
in our daily life. We have also seen its importance and the various types that exists. Carrying out
a literature review provided insight on what RTOS is all about and the latest development in this
field. In addition, we also encountered the real time key considerations that are involved such as
latency, memory management, garbage collection and so on. Moreover, developing the ATM
Transaction system provided useful knowledge about multithreading in the JAVA language as
well as C# language using Visual Studio. Analyzing the results of profiling helps us gain much
more knowledge about memory leaks, heap management and CPU management for JAVA as
well as C#. However, profiling and analyzing for C# proved to be difficult since resources is
limited and the data that is given is just a basic general overview of the processes taking place.
7 REFERENCES
Costa, P., 2020. [online] Pdfs.semanticscholar.org. Available at:
<https://pdfs.semanticscholar.org/65af/32ca93d9069fbb43760f1f3ccfb81468848e.pdf>
[Accessed 14 March 2020].

UKDiss.com. 2019. Real-Time Operating Systems Advantages And Disadvantages. [online]


Available at: <https://www.ukdiss.com/examples/real-time-operating-systems-advantages-
disadvantages.php> [Accessed 14 March 2020].

Petters, S., n.d. [online] Cse.unsw.edu.au. Available at:


<https://www.cse.unsw.edu.au/~cs9242/08/lectures/09-realtimex2.pdf> [Accessed 14 March
2020].

Williams, R., 2006. [online] Mobt3ath.com. Available at:


<https://www.mobt3ath.com/uplode/book/book-26266.pdf> [Accessed 14 March 2020].

Haines, S., 2014. [online] Rockvalleycollege.edu. Available at:


<https://www.rockvalleycollege.edu/webadmin/upload/Top-10-Java-Performance-
Problems.pdf> [Accessed 14 March 2020].

Hambarde, P., Varma, R. and Jha, S., 2014. [online] Iranarze.ir. Available at:
<http://iranarze.ir/wp-content/uploads/2018/12/F1156-English-IranArze.pdf> [Accessed 14
March 2020].

Chang, Y., 2007. [online] Cs.york.ac.uk. Available at:


<https://www.cs.york.ac.uk/rts/documents/thesis/yang07.pdf> [Accessed 14 March 2020].

Electronics, R., 2014. [online] Renesas.com. Available at:


<https://www.renesas.com/cn/en/doc/products/tool/apn/res05b0008_r8cap.pdf> [Accessed 14 March
2020].

Bettati, R., n.d. [online] Faculty.cs.tamu.edu. Available at:


<http://faculty.cs.tamu.edu/bettati/Courses/663/2016C/Slides/OS.pdf> [Accessed 14 March 2020].

Walls, C., n.d. [online] Ese-kongress.de. Available at: <https://ese-


kongress.de/custom/media/ESE_2019/Presentation-Mentor%20Graphics-Colin%20Walls.pdf> [Accessed
14 March 2020].

You might also like