473,386 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

python internal hacking: multitasking, interrupts, and the like

A brief introduction for python-list: Unununium is an OS being developed
in Python wherever possible. This message is phrased for the Unununium
list, but as the questions are about hacking cPython, I have CCed
python-list as well. <http://unununium.org/>

As not everyone has heard yet, the current scheduler is insufficient for
our needs. The biggest restriction is that it allocates threads in pools
of 32, which becomes a problem when we need 8M * 32 stacks to accommodate
Python. Furthermore, statically allocating huge stacks is a problem
anyway, and we need to move to a multiple address space model.

To that end I've decided to get a new scheduler, and I want to do it in
Python. There are some things to consider:
Traditional multitasking is rather inefficient. Switching stacks and
blowing away the TLB cache on each process switch is a waste of time.
Two alternatives come to mind, Twisted's select() based reactor which is
a purely event based model, and stackless, which provides 'tasklets'.

The problem with Twisted is that it requires code to be rewritten in
terms of callbacks that happen in response to events. This works well
for applications designed that way, but we need a solution that works
for all applications, even those not in Python. Furthermore, scheduling
is coarse and purely cooperative, which is efficient for a single
application but does not scale to an entire system. However, it is
valuable to consider Twisted as a method for application-level
multitasking.

The problem with Stackless is that I can't find any information on it.
I've made inquiries to their mailing list about how tasklets are
scheduled and received no response. Perhaps someone knowledgeable has
subscribed since I last asked this question. If so, please share your
knowledge.
I'd like to use an existing solution, but that doesn't look like it will
happen. In that case I need to better understand Python's internals to
write a scheduler with it. I think if I were able to attach a python
routine to an interrupt handler, I could do with a minimal amount of
supporting C and assembly. However, I'm not sure how I can do this. The
problem is the infamous GIL; I don't know how I can acquire the lock
without multiple threads. Perhaps I don't need to acquire it if I'm
careful about what data I access, but I don't know enough about Python
to answer that. Further complicating the issue is that our build of
Python does not include thread support, because...well, there is none!
Please share your ideas.
Jul 18 '05 #1
0 1635

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Will Stuyvesant | last post by:
I never used the popen or popen2 libraries but it is my understanding that they can capture the output of console based programs. Is it also possible to send keystrokes to console base programs? ...
20
by: Daniel Ehrenberg | last post by:
Io (www.iolanguage.com) is a new programming language that's purely object-oriented (but with prototypes), has a powerful concurrency mechanism via actors, and uses an extremely flexible syntax...
24
by: Richard Blackwood | last post by:
Is it possible to prototype an operating system in Python? If so, what would such a task entail? (i.e. How would one write a boot-loader in Python?) - Richard B.
34
by: Ville Voipio | last post by:
I would need to make some high-reliability software running on Linux in an embedded system. Performance (or lack of it) is not an issue, reliability is. The piece of software is rather simple,...
65
by: Amol Vaidya | last post by:
Hi. I am interested in learning a new programming language, and have been debating whether to learn Ruby or Python. How do these compare and contrast with one another, and what advantages does one...
13
by: Yannick | last post by:
Hi, I would like to program a small game in Python, kind of like robocode (http://robocode.sourceforge.net/). Problem is that I would have to share the CPU between all the robots, and thus...
206
by: WaterWalk | last post by:
I've just read an article "Building Robust System" by Gerald Jay Sussman. The article is here: http://swiss.csail.mit.edu/classes/symbolic/spring07/readings/robust-systems.pdf In it there is a...
35
by: eliben | last post by:
Python provides a quite good and feature-complete exception handling mechanism for its programmers. This is good. But exceptions, like any complex construct, are difficult to use correctly,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.