[Oz] Time allocation for threads (and other questions)
Peter Van Roy
pvr at info.ucl.ac.be
Fri Jun 16 17:04:49 CEST 2000
>
> Hi,
>
> Is it possible to control time allocated to threads in detail? In
> particular, I want equal time for separate subtrees in the thread forest
> (ie I have certain parent threads for which the total time allocated to the
> parent and children should be the same). Each subtree is compute-bound.
>
> It might be clearer if I explain why:
>
> I'm considering implementing a simple environment in which separate agents
> compete. The agents interact asynchronously with the environment (and only
> indirectly, through the environment, with each other) and have limited
> information - I want to look at the trade-off between agents that do little
> processing and so interact more with the environment and agents that do
> more processing but, therefore, interact less frequently.
>
> At first I thought thread fairness would guarantee this, but as I learnt
> more about Oz I realised that I would want to use more than a single thread
> in each agent. If I understand things correctly this would mean that the
> agent using more threads would (could) get more CPU time.
This is correct. In a Mozart process, the CPU pie is cut into three pieces,
low, medium, and high priority. Each thread has a priority level. Each
priority level has a guaranteed share of the CPU; it may get more if other
levels use less than their share.
Threads are intended for *cooperative* concurrency: entities working
together to achieve some goal. They are not intended for *competitive*
concurrency. An agent can effectively monopolize a priority level by
creating many threads at that level.
But competitive concurrency support is exactly what the OS provides with
the 'process' concept. A Mozart process can create other processes with
the 'Remote' module and install software components there (a component
specification is a first-class data structure called 'functor'; installing
it creates a new module or software component). There is system support
to make communication between such processes very efficient.
So right now, if you want to control CPU use of agents, you have to
keep them in their own process. Because of network transparency,
usually no code has to be changed in the agent itself.
> If all this sounds a bit serious I better add that this is just for fun -
> in time I hope to open up the environment and see whether I can persuade
> others to send agents to compete. (Which brings up another question -
> what's happening about security (controlling access to system resources)?).
If we assume no tampering at the implementation level, then security is
easy to provide: just give an agent limited versions of system resources
when installing it on a process. This is possible because these resources
are accessed through software components. When a component is installed,
its resources are specified. The language itself is completely secure
(it has the "capability property": language references are unforgeable
and give well-specified rights).
There's no implementation security yet, though. It's something that we're
working on and that will eventually be part of the system.
>
> Thanks,
> Andrew
>
> PS I'm new to Oz - as is probably obvious - but from what I've seen, it's a
> very impressive language. I hope it continues (another question - is it
> likely to remain supported for some time? It's a pity that "academic"
> languages like this often fade away before getting widespread use.) And
> the documentation is exemplary!
> http://www.andrewcooke.free-online.co.uk/index.html
Well, Oz has been publicly available since 1995 and the distributed
implementation Mozart since Jan. 1999. It is our research vehicle
and several very nice applications have been written in it. Two
particularly nice ones are an Expert System for Cow Disorders, with
extensive data base, and Friar Tuck, a tournament planner. See the
Mozart projects page.
Peter Van Roy
-
Please send submissions to users at mozart-oz.org
and administriva mail to users-request at mozart-oz.org.
The Mozart Oz web site is at http://www.mozart-oz.org/.
More information about the mozart-users
mailing list