• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
 
Real-Time Operating Systems Homework Report
Vittorio Giovara26/01/2009
Abstract
In this document a solution will be described for implementing a concurrent programmingscheme in a real-time operating system.The first part of the document will carry out the design planning, describing the mainprocedures and functions in pseudo-code and taking care of two possible issues,
deadlock 
and
starvation
. Moreover an actual implementation of the problem will be discussed for theRTEMS Operating System.In the second part a complete working implementation of the solution will be presentedfor a general purpose operating system, providing profiling and time analysis.
Contents
I Preparation 2
1 The pseudo-code 2
1.1 Functions and Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.2 Proposed Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 Message Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Dealing with deadlock and starvation issues 3
2.1 Denitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.2 Proof for deadlock free solution . . . . . . . . . . . . . . . . . . . . . . . . . . 42.3 Starvation free condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3 Initial RTEMS solution 4
II Implementation 6
4 Development details 6
4.1 IPC Mechanisms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
5 Proling 7
5.1 Testcases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75.2 Mean and Maximum Wait Time . . . . . . . . . . . . . . . . . . . . . . . . . . 125.3 Execution Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
 
Part I
Preparation
1 The pseudo-code
1.1 Functions and Structures
void sync (int w)
function for normal processes to put themselves in a passive wait; the argument
w
representthe weight of the wait;
void admit (int a)
function for the master process to wake up some the waiting processes; the argument
a
determines which processes in the pool are actived;
send
and
recv
functions for implementing message passing with fixed lenght format; the naming schemeis
direct 
,
asymmetric
for the
asynchronous
send
with infinite buffer.
information vector 
contains general data about every process: it stores the
process identifier 
, its
status
(blockedor running), its
weight 
and the
age
, which counts how many times a process eligible foractivation has not been woken up after an
admit
; an additional field is required for thefinal solution to work, that is the
fdlisten
, need for communicating with the process;
vector order 
is a vector containing the ordered (by age) list of all the processes that are activated by an
admit
;
1.2 Proposed Solution
void sync (int w)
1.
check if the argument 
w
is greater or equal than 1 and less or equal than 10;
2.
inform M of the status change with a
send
;
3.
perform a blocking
recv
;
4.
upon message receiving, check if the format is correct;
5.
if the message is correct, return, else remain in wait.
void admit (int a)
1.
send a message asking the server to perfom the wake up of some processes;
2.
return.
2
 
server process
1.
spawn a given number of 
P
and 
Q
processes and initilize the “information vector”;
2.
enter endless loop
3.
wait with a
recv
for an action to perfom;
4.
if a
sync
has been called, update the status of the process in the information vector;
5.
if an
admit
has been called perform the following:
6.
initialize a list (vector of index) for storing the set of processes that are going to be activated (called “vector order”) ;
7.
select the set of waiting processes with their weight and age from the information vector;
8.
order the vector from highest age to the lowest and initialize
pound
equal to
a
;
9.
for every element in the vector,
send
a wake up if its weight is less than pound and if pound minus the weight is positive;
10.
when a wake up is sent update the pound by subtracting the weight of the process; in thisway both the conditions of the assignment are respected;
11.
update the information vector with the new status for the selected processes and the incre-mented age for the unselected ones;
12.
repeat loop.
1.3 Message Format
The format for the exchanged messages is to use 2 integers (8 bytes); the first integer is used fordistinguishing whether a
sync
or an
admit
has been called, while the second integer containsthe argument of the
admit
(sent from the process
Q
to the server
M
).
2 Dealing with deadlock and starvation issues
2.1 Definitions
As with most of concurrent programming schemes, it is possible to incur in two important prob-lems:
deadlock 
and
starvation
.The former is situation whereby a set of processes cannot exit a from a given status becausethey are waiting for an event that can be generated only by a process inside the blocked set.This type of problem cannot be resolved (because deadlock detection algorithms are rarely imple-mented in the system), but only avoided beforehand, implementing secure states.The latter on the other hand is a condition in which a given process never manages to access aresource because other processes gain access before it, even if it is ready to execute. This is alsocalled indefinite wait. Usually this kind of problem appears in priority scheduling systems with noaging techniques.3
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...