Monday, October 30, 2006

pthreads: when light becomes heavy

Pthreads or POSIX threads are said to be "light weight processes" and are usually recommended instead of fork(), exec() and calls to shared memory and semaphore routines. This is because a thread creation is supposed to take less resource for creation and cheaper for switching between them. Threads (pthreads) may be implemented at OS level or supported by appropriate hardware.

Though it seems that pthreads take up much less resources, but the way an OS is configured can drastically alter the resource requirements of creating pthreads. This was typically the situation I landed up when I was using pthread via Python on a large SGI Altix system (google for: ANUSF).
The stack size on this altix system was set to a default of 1GB, which resulted in stack allocation of 1GB per thread even if no work (or memory allocated) was done within these threads. Initially I though that this was a problem with Python interpreter on IA64, so i coded up a small skeleton code in C using pthreads; to my surprise this also resulted in allocation of 1GB per thread. Next, I tried using OpenMP "threads" and was pleased to see that the memory of this process didn't shoot up like its pthreads counterparts.

After some consultations with my instructor, I discovered that you can set the stack sizes of pthreads using: pthread_attr_setstacksize() function (check google codesearch for examples). But all this meant rewriting all my code in Python in C or writing a full thread wrapper for Python in C.

So determined not to do that I set out finding new ways to handle this in Python itself. I discovered that you could actually set the stack size in Python, but to my dismay this had been only introduced in the latest 2.5 release, and there was no way that the 2.3 version of Python on the Altix machines were to be updated.

After googling around a bit i discovered what is called as stack-less python. This essentially reduces usage of python stacks by maintaining a common stack. But again this had many problems, first and foremost was this was not standard python and had to install it separately. Secondly there is a lot of debate on the merit of using stackless python and the disagreement with the main Python development community.

Ruling this out, by sheer chance i googled for "microthreads" and came across an interesting article by David Mertz. This article suggested using generators in Python to achieve user level cooperative multithreading. This was really an interesting article for me as it was the first time that I was introduced to the wonderful generators in Python. I began toying around this idea, but finally discovered that I would still be requiring preemptive multithreading for my particular application.

I had known the use of "ulimit" in bash (or "limit" in csh), and had frequently used it to query the system limits. But had never intentionally used it to change those limits. As soon as I remembered this command, it was very obvious what I would be doing: wrap up python execution in a shell script, and issue an ulimit with 8MB (or so) as the maximum stack limit. So only the python process will be affected by this change, and the rest of the system process remained intact.

In the end the solution to the problem seemed to be simple, but learned a lot in the process.
Now I am writing a small MicroThreads interface using generators, which I will be soon posting here. (Note: there are many more implementation using this idea, but I just want to have some fun with generators)

day light saving: googly!

Today, i was taken unaware of a practice followed in countries not near equator.
Canberra, where I am presently staying had a daytime saving for +1 hour for the "summer time" .. and evidently not aware of this change, I reached one hour late to my work place. Surprised, my instructor asked me how come you are late today?
late? i looked at my mobile and said "probably u r early, its 8:45am".
"no, the time changed on saturday ... it is quarter to 10!" he said promptly with a smile.

... after some time I realized what day time saving was all about: only heard of now experienced!
Have a look at http://webexhibits.org/daylightsaving/c.html to know more about the rational behind it.

Later on I realized that my nokia 6600 has an option to adjust automatically to day light saving which obviously was set to off!

Tuesday, October 10, 2006

and the web office ...

google just combined its writely and spreadheet app:

http://docs.google.com/

updated to blogger beta

just now updated to new blogger beta...

google code search!

google has release a wonderful code search utility!!

http://www.google.com/codesearch

it has found most of the code that i have released... except one MeTA Studio.
these seem to be many a projects which seem to have similar name!

Wednesday, September 06, 2006

collaborate over the wire (or without it!) with MeTA Studio

The new developements that have been going on in MeTA Studio:
- a peer to peer networking and discovery protocol
- talk application built over the above apis ...

u will have to wait for the latest binaries to be updated! so look back.
(excuse: the source is not yet in a state to be released .. will take time, can't say how much!)

take a look at some of the shots...


Saturday, September 02, 2006

Build ur own Tuxphone

yes, this is a pretty interesting site by Surj Patel and others that is in the process of describing how to build your own cell phone and load customized linux on it.

its really exciting and the work seems to have just begun!
visit http://www.opencellphone.org/ for details

Thursday, August 24, 2006

Indian Ocean Tsunami Detector

Is a really useful application written in PyS60 which according to the site:
".. is a tsunami prediction program that filters and analyses LIVE data from the United States Geological Surveys (USGS) Earthquake reading..."

update: mobihf and mobimol

Am happy to announce that the source of mobihf and mobimol have now been merged to PyQuante CVS, thanks to Rick.

Please see:
http://tovganesh.googlepages.com/s60

and the CVS:
http://pyquante.cvs.sourceforge.net/pyquante/PyQuante/MobiCode/

all further updates will be made to the above CVS.

Friday, August 11, 2006

on OLPC: why indian policy makers should rethink?

Till my last post of the OLPC (one laptop per child) subject, I was wondering whether someone in India had experimented with the idea of providing access to computers for underprivileged or rural kids?

I was pleasantly surprised to find the "Hole-in-the-Wall" project being run by NIIT in coordination with International Finance Corporation.

From the hole-in-the-wall site:
"The acquisition of basic computing skills by any set of children can be achieved through incidental learning provided the learners are given access to a suitable computing facility, with entertaining and motivating content and some minimal (human) guidance."
is some thing we should seriously look at, rather than outright scrapping of OLPC in india.

Dr. Sugata Mitra, Chief Scientist at NIIT, who is toying with the idea of providing computer access to the kids since 1982, and allowing them to acquire the skills and education on their own is a prime example of why such projects are needed at a large scale in India. And with the GOI honoring Dr. Sugata with Dewang Mehta award for Innovation in Information Technology, the government probably itself recognizes the need for such work.

India could set an example on how to make technology accessible to the masses .... only if we think right and take right decisions.

PS. To know more about the "Hole-in-the-wall" project visit: http://www.hole-in-the-wall.com/

Monday, August 07, 2006

Lost mobile phones: can they be found?

Yesterday while travelling back home from pune railway station to viman nagar, some rouge stole a mobile (samsung) from an unsuspecting girl in an overcrowded bus.
After reporting the matter to the conductor, he offered to stop the bus immediately to get it checked, but as commonsense suggested, this wasn't feasible as the person who stole it would have already disappeared. In any case I found that the attitude of the people really disturbing: instead of suggesting ways what to do next people were finding faults like 'her bag was open', 'its her mistake', 'you cannot find a lost mobile' and all that: not a single attempt the calm down the crying looser!
Any way after waiting for some time, I couldn't resist but offered to call up the customer care center (fortunately it was airtel, same as my service). And also advised to file an FIR with the IMEI (International Mobile Equipment Identity) number as early as possible. After few attempts i was able to get the a line to the customer care executive, to whom she spoke. To my surprise, in spite of giving all SIM details to the executive, she refused to block the SIM! and instead asked to call back after lodging an FIR! This was a real shocker for me.
In any case I am not aware of any other mechanism of tracking a lost mobile, than lodging an FIR and then asking the operator as well as the mobile manufacturer for blocking the stolen mobile.

I guess, with more of these thefts, we must device some way to track down these gadgets. And also people must realise that a lost mobile can be (and probably will be) used for unlawful activities. As law abiding citizens we must do all that is possible to avert such misuse. Thus, a theft of a communication device must be taken seriously.

In the end, i could not (and probably can't - at least for the time being) trace the lost mobile but at least brought a slender smile. :)


Tuesday, July 25, 2006

on OLPC and RTIA

Two disconnected issues. But the way in which policy makers are taking decisions (and giving reasons for them) on these apparently important matters should be of real concern and .

A few days ago, the HRD ministry had indicated that OLPC (one-laptop-per-child) program is *not* suitable for children of rural India... providing some absurd reasons like: ".. the problems (health) faced by rural child is well known, and would be further complicated by usage of laptop". and it goes on to give so many other reasons (by quoting foreign experts)! I fail to understand why no Indian expert is at all considered?

So is the case of Right To Information Act (RTIA) where an amendment to limited/ no access to "file noting" on certain "classified" areas is proposed. Similar acts in other countries were cited as example for the proposed amendment. This is simply not good for a health of democratic India, where we seem to be trying to do what others are doing, and simply not having our own views on these subject of prime interest to any democratic institution.

And as Arvind Kejriwal gets Magsaysay Award for the very RTIA that he and may others (including Anna Hazare) fought for, we simply wonder how our elected representatives are modifying a powerful act to suite some wested interests.

Friday, July 21, 2006

Blog of V.Ganesh

Blog of V.Ganesh

.... Hurray! It up again! So finally the ISPs and DoT, GOI seems to have figured out the "technical issues" involved in stopping access to only certain blogs.

... A real pity situation. But anyways I am happy, and hope that such incidences do not happen in India again. BTW, it would be interesting to see if some of the avid bloggers still file a PIL (which i guess they will) in Supreme Court? This would probably bring in some amendment to the IT Act, 2000 to include "blogs" ... its wait and watch.

Monday, July 10, 2006

INSAT 4C on GSLV fails

An hour ago I was watching the live telecast of the launch on DD. By now its very clear that we have not been successful in launching the INSAT series on Indian soil. This was the third launch attempt of the GSLV (cryogenic development vehicle), the first two have been a success and has placed weather satellites (kalpana I and II) in geo-synchronous orbit.

Hard luck for ISRO. The launch originally scheduled at 4:36 pm IST was postponed twice, first to 5:16 pm and then finally to 5:36 pm. So far no official reason for the failure has been given, but it is speculated to be a failure in the second stage of the GSLV.

The next plan of ISRO, if they are not going to hold up, would be another launch of GSLV in 2007-08 (http://isro.org/decade_plan.htm), and the much publicized lunar mission.

... hope for the best

Friday, July 07, 2006

lexicographical combination algorithm

have written a small article on generating combinations in lexicographical order. you can read it at: http://tovganesh.googlepages.com/comb.pdf

Friday, June 23, 2006

mobioo v0.1, first OpenOffice (odt) reader in PyS60!



ah well but a really basic one with following formating:
- paragraphs
- bold, italic, underline, strike-through
- font colors

not yet:
- bullets and numbering
- pictures and tables: probably never??

Get the source at:
http://tovganesh.googlepages.com/mobioo.py

And set a sample ODT (OpenOffice writer) file from here:
http://tovganesh.googlepages.com/sample.odt

Please note that you will need pyexpat for s60 installed on your phone which is available here:
http://pdis.hiit.fi/pdis/download/pyexpat/

PS. I will be making a SIS installer too shortly so check back!
In the previous post of BtSMS, be cautious about the UID, its a mock UID!

Wednesday, June 21, 2006

BTSMS v.0.1: forward your SMS over bluetooth and send SMS via PC

With BTSMS you can:
- read all your SMS (no MMS or bluetooth files)
- forward SMS over bluetooth as note files
- send SMS via PC using pcsms.py client
( the pcsms.py client requres you to have:
> python interpreter 2.4 or higher on linux or windows xp
> pybluez extension library available from: http://org.csail.mit.edu/pybluez/
> and ofcourse a bluetooth transreceiver (dongle) connected to your PC
)

- Get the source and SIS file for this application at: http://tovganesh.googlepages.com/btsms_app.tar.gz


Tuesday, June 13, 2006

My Way News - Hawking Says Humans Must Go Into Space

My Way News - Hawking Says Humans Must Go Into Space

The survival of the human race depends on its ability to find new homes elsewhere in the universe because there's an increasing risk that a disaster will destroy the Earth, world-renowned scientist Stephen Hawking said Tuesday.


(...my take worth reading and giving a serious thought)

update at: http://english.people.com.cn/200606/14/eng20060614_273839.html

When answering a question about how he copes with frustration, which also mentioned a paralyzed accident victim Bun Tsai in Hong Kong who appealed publicly for legalized euthanasia, Hawking said, "The victim should have the right to end his life, if he wants.

"But I think it would be a great mistake. However bad life may seem, there is always something you can do, and succeed at. While there's life, there is hope." Hawking is in the best position to say so, his action of defeating physical difficulties has proved his word right.

Wednesday, June 07, 2006

google spreadsheet

there has be a lot of press attention to the realease of spreadsheet application by google, but i guess many of us don't know a much better, functional, online spreadsheet tool (with can be added on your google home page aka. google ig) by: IROWS

i find it more usable because:
- has lot more features, charting support!
- right click works as in OpenOffice (i do not use excel)
- it can save & read in OpenOffice format!, google can read and write only .xls and .csv format

but probably these features will get added into google spreadsheet with time.

Wednesday, May 24, 2006

new version of mobihf

get the stuff from:

http://tovganesh.googlepages.com/s60

and let me know the feedback on the previous post on math library in symbian!