To elaborate a bit more, you can think of the scheduler as the "main
loop" of the thread.
It operates within a single thread and is responsible for determining
which AO should run
next among all those ready to run. It also handles timers (i.e., AOs
that request to run
after a specified amount of time). The scheduler is implementing a
cooperative multi-tasking
system within a thread as Dave mentions. Each AO is responsible for
doing a small amount of
work when run and then actively yielding to allow others to run. It is
also possible to run multiple threads with the
Opencore framework. In that case each thread using AOs would have a
separate instance
of the scheduler running.
Regarding the specific question about iNumAOAdded, it is simply a
counter within the scheduler that
increments for each AO added to the scheduler and is never decremented
or reset during the lifetime
of the scheduler instance. It is optionally used to alter the
scheduling logic (i.e., determine which AO
to run when multiple AOs are waiting to run based on which was added
first). However, the default
scheduling rule is based on a FIFO queue to implement fair scheduling
in which case this counter
value isn't used.
On Dec 5, 10:05 pm, Dave Sparks <[EMAIL PROTECTED]> wrote:
> Each task (Active Object or AO) has a run function that does some work
> and then relinquishes control back to thescheduler. The task can
> request additional time, schedule itself to run again at some future
> time, or wait for another task to send it a message to wake it up.
>
> On Dec 5, 1:05 am, jason <[EMAIL PROTECTED]> wrote:
>
> > Hi Dave Sparks,
>
> > Thanks :-)
>
> > Would you like to describe theschedulermodel? It may help me to
> > understand the opencore arch.
>
> > Best Regards
> > Jason
>
> > On Dec 5, 4:03 pm, Dave Sparks <[EMAIL PROTECTED]> wrote:
>
> > > OpenCore has a cooperative multi-taskingschedulerthat runs on a
> > > single pthread. You will probably recognize theschedulermodel if
> > > you've worked on another prominent OS for mobile devices.
>
> > > I'm not that familiar with theschedulercode, but I believe that's
> > > the equivalent of a thread ID.
>
> > > On Dec 4, 11:37 pm, jason <[EMAIL PROTECTED]> wrote:
>
> > > > Hi,
>
> > > > I have some questions aboutscheduler:
>
> > > > 1. Is there aschedulerin one thread?
> > > > 2. In multi-thread case, how to schedule these threads byscheduler?
> > > > 3. I see the iNumAOAdded++, but no iNumAOAdded-- as follows
>
> > > > void PVActiveBase::AddToScheduler()
> > > > {
> > > > iThreadContext.EnterThreadContext();
> > > > if (iThreadContext.iScheduler)
> > > > {
> > > > iAddedNum = iThreadContext.iScheduler->iNumAOAdded++;
>
> > > > ...
> > > > }
>
> > > > }
>
> > > > Does it adds the counter as calling AddToScheduler?
>
> > > > Best Regards
> > > > Jason- Hide quoted text -
>
> > > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"android-framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-framework?hl=en
-~----------~----~----~----~------~----~------~--~---