Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1664 pj 1
ÐÏࡱá>þÿ	LNþÿÿÿKÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿì¥ÁM ð¿‡(bjbjâ=â=	.D€W€W‡$ÿÿÿÿÿÿllllllll€~~~~’<€,2ÚÚÚÚÚÚÚÚ€+‚+‚+‚+‚+‚+‚+$3- S/\¦+lÚÚÚÚÚ¦+ŠllÚÚ»+ŠŠŠÚ"lÚlÚ€+ŠÚ€+ŠèŠrâl)¤ll\+ÚÎ°\
,Ä€þ~ü*\+$Ñ+0,&*6¯/üŽ¯/\+Š€€llllÙTHE REAL-TIME CAR GAME
(A Project Implemented on the S.Ha.R.K)







Developed By:


Amit Doshi
Sangeetha Sudhakrishnan
Saurabh Kumar




































Problem Definition:
	The Aim of this project is to model cars with different properties which try to avoid collision among themselves and on the other hand reach the petrol station.
Real time Requirements: This toy-example was used to experiment with the shark real time kernel. Our example has the following real time requirements:
The cars must be able to detect collision in time! 
the system must model “movement” of car on graphics which is correctly visible to human eyes.
The execution statistics must reflect the most current (as far as possible) behavior of the system.. 

Design:

Our system has Hard, Soft Periodic and Aperiodic Tasks.
We have created five tasks:
Car
Repaint
Jetctrl 
Jet Dummy
JetSlide
Mouse Hook
Keyboard Hook

Besides we have mouse and keyboard as sporadic tasks in the system.

Description: 

Task Car:
	This is a hard periodic task which models the car in our system. The cars do the following:
Each car has a different maximum speed (shown by different color) 
The cars start at zero speed and accelerate up to their maximum speed.
When the cars find another car task within a certain range they deviate from their “desired track.” and reduce their speed
The “desired track” is moving towards the petrol station(the yellow square in out system)
In cases where they are unable to deviate they collide with cars are on the same path. Collision results in restarting of the car from a new random position. 
Behavior:
The Cars have been modeled as having the following characteristics namely
	1.Speed
	2.Acceleration
	3.Angle of Deviation
There are three types of Cars in the system, which differ on the basis of their speeds.
	When a car finds another car in its vicinity, it sets a flag, ’warning’, which helps the car in anticipating a collision, and thereby, deviate from the current path. Also the current speeds of the car are reduced. 


Mouse and Keyboard Hooks.
We have allowed to change the position of the petrol station with :
Mouse
Keyboard
The mouse and keyboard hooks provide a suitable example of sporadic activities(tasks).These are internally modeled as soft tasks by the kernel library. The handlers for these hooks must change the position of the petrol station. The position of the petrol station is used by the car tasks. These handlers must be short. For all these requirements we have used fast cabs to store the coordinates of the petrol station.

The collision avoidance of each car requires the positions of other cars in the system. The coordinates of the other cars are stored in ports. A car writes its current position on the ports while other cars ret rive this from the port. Ports for each car is maintained uniquely by using the carid. Each port allows one writer and with multiple readers and the read and write sections are mutually excluded by the ports.

Movement of the cars is implemented by incrementing along the X and Y axes. The direction along which to move is decided depending on the position of the petrol station.


Task Repaint:
	This task repaints the :
Border
Petrol Station

The border is erased when the car task approaches it. Same is true for the petrol station. To handle these we have created a soft task called border.

It is a soft task

Task JetCtrl , Jet Dummy, Jet Slide:
.
The Jetcontrol Tasks have been used to precisely estimate the system load.The three tasks namely, JetDummy, JetSlide and JetCtrl are scheduled using the CBS algorithm. In this algorithm, every task has a period and a Mean Execution Time(MET).The Tasks are scheduled using EDF. When a task executes more than the MET, its deadline is postponed by a period. For each task, the mean execution time and the maximum execution time is determined.The Kernel should be enabled explicitly to record the JET information for the tasks. This is done at creation time. The following primitives have been used to retrieve the information1. Jet_GetStat(PID p, TIME *sum, TIME *max, int *n, TIME *curr):-sum: the total execution time since the task was created.-max: the maximum time used by the task instance.-n: the number of terminated tasks.-curr: the total execution time of the current instance.
2. Jet_GetTable(PID p, TIME* table, int n)This returns the last n execution times of the task. the function returns, the last minimum value registered in the Jet_Table_Dim.The Kernel maintains a Proc_Table for the tasks. These values are used by the Jet control tasks to display system information.
(We took this from the jumping ball example in shark demos to analyze the system we modeled)

Our Observations:
We have tried running our example with different resource sharing algorithms. Some of our observations are as under:
Our Car Task is hard real time task. However the execution time varies a lot . This is because the for loop for collision check has to be done for all the cars if collision is not detected.
The initialization of the task in the first cycle increases the execution time of the tasks.
It was interesting to see that the first of several car tasks created had a small worst case execution time while others had larger values(two times greater).However when we do a task end cycle for the first instance just after initialization the values even out.
The system was becoming un-feasible at different number of cars when we tried to use different resource sharing algorithms. Currently we are employing NOP and the system becomes unfeasible for 12-16 cars. 
Our current implementation could perhaps be better modeled by separating the task into four different tasks all belonging to the same group. This is covered in the next section.

Suggested Improvements:

Currently we have a architecture trying to have both periodic and aperiodic tasks and try to study their effects. We however think that we could model our CAR task as four different task(and this would  perhaps more faithfully represent the real system).Our suggested architecture is as follows:
Update Task: This is trying to model the sampling of position of the cars. Its responsibility is to update the x –y coordinates of the car and write it on the ports. The updating simulates the “movement” in the actual system. Besides this computation also accounts for the “latency” in sampling.(Of course not calibrated to the real stuff ( , but that could be done too!)
Target_Find Task: It searches the petrol station and tells the direction(angle to the update task)
Collision Task: It tries to read the “most” current position of other cars. This could possibly be done in two ways:
Read the position values in the shared data written by update task of all the cars. This models a system like  h one employing gps to find he location of other cars.
Read the pixel colors. And find if there is a car nearby. This could be heavy if we try to read all the pixels in the given range every time.  better approach is to increase the “range” only if it is not found within that “chuck”. This would allow the task to have a very high WCET but a small mean execution time.
Task Display: This tasks uses a shared resourse..the graphics card. So its better to model it 
       separately from the hard tasks. 
Timing and categories:
      We have tried to implement this idea in Update.c, Target.c, Collsion.c ,Display.c. (It doesn’t work as yet but we would try to complete this in the near future (!!).
 In this model we have Update as a hard task. It computes the new position and writes to a CABS buffer the current values. It has hard real time requirements. Typically the display on the screen will guide our visual perception of movement on the screen. This display is typically done every 40 ms. To faithfully “sample this movement”  we must do that at  least twice the frequency(Nyquist criterion). So we should do update task every 20 ms. (we could try to do a little better too!).So lets say the update task is in the range of 10 to 20 ms and is periodic and hard real time. We expect the system to have a small wcet. 
The target task and collision tasks are both soft tasks which model the “controllers” of the cars. The target task has the objective to find the angle at which the car must move to reach he petrol station While the collision tells if there is an impending collision . Both these tasks could have values in the range of 20 –40 ms. The display task reads the current position and displays on the screen every 40 ms. It is also a soft task.


Conclusion:
We were trying to model different kinds of tasks in our system. We have(periodic) hard, soft and sporadic tasks in this system. We tried to use different resource sharing algorithms and used cabs and ports to achieve resource sharing.
Shark kernel allows evaluating different scheduling and resource algorithms by simply changing the modules employed. This provides and ideal platform for carefully selecting a proper architecture before deploying on the real system. 
It helped us:
Identify a better architecture based on the performance of our system.
Use different in built-modules and find the one which suits the best for our application
Besides, the kernel also allows to implement new resource scheduling modules and resource sharing modules. 

 
?ATUˆ­Áczòùúû\x¢ÆÖåîÿ¨ÃÈ
Þ
aoJmq»¼*+âã#&_`‘’µ¶îðž |}Ž¨Àéô<=ûòíãíÝíÕíÏíÆÕÆíÁíÕíÆÏíÏíÕíÕíÏíÏí²©²©²©²©²©²©²©²©²©²©²íÏÆÕíÆíÕí¡	jJðmH	sH	PJaJmH	sH	0JCJOJQJ^JmH	sH	mHsH5>*\mH	sH	>*mH	sH	5\mH	sH	5mH	sH	5CJaJmH	sH	mH	sH	CJaJmH	sH	CJ,aJ,??@ABCDEFTUVay‡ˆúõõõììììììßßÍÍ͐<$$If–F”TÖºÿæ,
6`”üÿ”b”ö6ÖÿÖÿÖÿÖÿ”4Ö
2
Faö$$„üÿ„b&`#$/„Ifa$$„Ô
„Ä^„Ô
`„Äa$$„Ä`„Äa$$a$$a$‡(ýˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥ýýýýýýýýýýýýýýýýýýýýýýýýýýýýý¥¦§¨©ª«¬­Ácú.Œòóûü4PT\eoxƒ‘’ýýýýýýýýýýýøøøýýýýýóóóóóóóí„h^„h
3
&F
4
 
5
 
6
 
7
 
8
 
9
 
10
 
11
&F„Ä^„Ä
12
 
13
 
14
&F„h`„h	„h„\^„h`„\„h^„h'õ§¨ÀÁé]À5Û u  ´ `!Ñ#‡%ˆ%‰%•%€&j'x'ùôôîììæáááÜÜáîììÖÖÖììÖÖÖ„Ä`„Ä
15
&F
16
&F„h`„h„h^„h
17
 
18
 
19
 
20
 
21
 
22
 
23
 
24
 
25