Limiting thread intruction count
mac4-devnull at theory.org
Sat Jul 7 20:01:43 CEST 2001
In article <3B4721F3.BA771F79 at engcorp.com>, "Peter Hansen"
<peter at engcorp.com> wrote:
> Neil Macneale wrote:
>> Is there a way to limit the number of instructions executed by a thread
>> to a certain number?
> What do you mean by "instructions"? Machine language opcodes? Python
> bytecode instructions? Python source instructions ("statements")?
Yes, bytecode intructions.
>> The idea is that I have a game where people play there code against
>> others, and I would like to have some granularity in the number of
>> intructions each thread executes in a given time frame.
> Are you doing this to make the game "fair"? In what sense?
> Would you then need to consider the total amount of processing time used
> by a given thread? Or are you trying to see how efficiently (in terms
> of source lines of code) your players can code their algorithms, by
> putting a limiter on their code at a higher level such as source lines
> of code executed per unit time?
I want to give each thread the same amount of processing time. The way
the game works is that each player needs to write a program which
competes with other programs, or AI some might say. More computation is
an advantage, so we want to encourage players who can figure out the
most efficient algorythm.
In the game, computation will cost a player, in the form of negative
points or something. It would also be suitable if there was a way to
determine who many instructions were made after there program returns.
That may be equally impossible though.
> By the way, Python can, depending on the platform, already do some kind
> of round-robin style of multithreading (switching threads after a given
> number of Python bytecode instructions) which may have an effect similar
> to what you are trying to achieve, but I suspect what you are really
> looking for can not be found in that way.
So round robin scheduling is automatically used? The game is being
written strictly for unix; is there a way to find out if the unix
version uses round robin scheduling?
To reply to me via email, remove the '-devnull' from my address.
More information about the Python-list