Thursday, May 28, 2009


My first visual in PyGame ! THE TRAIN ! .....

Fig 1. PyGame , Game Development in Python

One of the first motion pictures was 50 second screening of a train , I took a leaf out of that. My first visual in PyGame is a train passing through a field with birds flying away in the sky.

The visual was made using 4 sketches or rather 3 'sprites' , One for the train , One for the setting and 2 for birds in either directions. The sound effects were my efforts to record train sounds from the London Underground and also the Southern Rail , and then painfully converting them to ogg files.

Fig 2. Screen-shot 1

Fig 3. Screen-shot 2

Video 1 .The Train

My first efforts yielded some success !

(1) The train moves !

(2) The birds in both the directions gives a more realistic effect !
(3) 3 movements incorporated in the same scene !
(4) The sound effect was icing to the cake

(5) All of it , from conceptualisation to realisation was mere 4 days !


(1) The train 'glides through' I wish I could make the wheels to go round
(2) It is all too sketchy , B/W !
needs some glamour !
(3) The sound is not in sync with the train's movement
(4) Lack of an user input !
(5) All looks a bit kiddish !

No programming discussion is ever finished without the code !

The code is a single python program ( , available in Reference (2) .

Sunday, May 24, 2009



WINDOWS does not support multithreading concurrent and real-time structures. What an irony !.The most popular OS does not allow systems and structures which can control the most breathtaking technologies of the day. Aerospace , trains, nuclear power plants and other state of the art embedded technologies cannot use WINDOWS !

When I learned about Real-Time and Concurrent Systems ,it was not very acceptable that Microsoft would make such a redundant OS. A bit of dabbling on the internet led me to
Article Number 22523 in Microsoft knowledge base.

Fig1. Article 22523
Which clearly stated that ,

"In no sense can Microsoft Windows be considered a "real-time" system. It is a message-driven, event-polling system, with nonpreemptive scheduling".

Being initiated in Windows and using it for about ten years , did make me stubborn and I tried to look for other alternatives which would
allow to construct real-time structures in Windows.

Cygwin came to my rescue ! However on running threads in POSIX and tasks in Ada, I realised that it is only a cheap makeover.

Python and Ada however worked in windows , Ada because it is a concurrent language and platform is not an issue. Python did execute the threads , though on a closer inspection it revealed that Python reduces the concurrent codes to their sequential evil twin brother.

A simple code which which prints out 'Hello World' and the thread number ;

Fig 2. The threading code

gives slightly different results with different OS. When run on Ubuntu Linux ,

Fig 3. Execution in Ubuntu

The order of execution of the threads is 3,4,1,5,2 then 1,2,3,4,5 and then 5,4,3,2,1. Thus the order of execution is non-deterministic , typical of real-time systems.

However on Windows ,

Fig 4. Execution in Windows, 'evil twin brother'

the order of execution is deterministic , as seen above. Thus windows prevents the real-time characteristics of non-determinism and reduces it to sequential processes.

Linux confirms the standard characteristics of concurrency as nondeterminism and preemption , hence a joy for all concurrent programmers. Seems Bill Gates got it wrong this time !