OpenCore学习笔记(1)

一、OPENCORE 之 Scheduler


OsclScheduler
OsclExecScheduler
OsclExecSchedulerCommonBase

 

 

1. OsclScheduler::Init()

→ int AuthorDriver::authorThread()
→ OsclScheduler::Init("AndroidAuthorDriver");
→ OSCL_TRY(error, mAuthor = PVAuthorEngineFactory::CreateAuthor(this, this, this));

→ OSCL_EXPORT_REF void OsclScheduler::Init(const char *name, Oscl_DefAlloc *alloc, int nreserve)
→ OsclExecScheduler *sched = OsclExecScheduler::NewL(name, alloc, nreserve);
→ sched->InstallScheduler();

→ OsclExecScheduler * OsclExecScheduler::NewL(const char *name, Oscl_DefAlloc *alloc, int nreserve)
→ self = OSCL_PLACEMENT_NEW(ptr, OsclExecScheduler(alloc));
→ self->ConstructL(name, nreserve);

======
AddToScheduler();
PendForExec();
======

2. OsclExecSchedulerCommonBase::iReadyQ

→ status_t AuthorDriver::enqueueCommand(author_command *ac, media_completion_f comp, void *cookie)
    → mCommandQueue.push_front(ac);
    → PendComplete(OSCL_REQUEST_ERR_NONE);

→ OSCL_EXPORT_REF void OsclActiveObject::PendComplete(int32 aStatus)
→ void PVThreadContext::PendComplete(PVActiveBase *pvbase, int32 aReason, TPVThreadContext aCallingContext)
→ void OsclExecSchedulerCommonBase::PendComplete(PVActiveBase *pvbase, int32 aReason, TPVThreadContext aThreadContext)
    → iReadyQ.Add(pvbase, false); /// 将一个AO添加到iReadyQ中,并恢复BlockingLoopL

3. PVActiveBase::Run()

两种情况,但似乎第二种没用到

iBlockingMode=true

→ int AuthorDriver::authorThread()
→ OsclExecScheduler *sched = OsclExecScheduler::Current();
→ sched->StartScheduler(mSyncSem); // AuthorDriver的构造函数在创建完AuthorThread之后进入阻塞状态,


→ OSCL_EXPORT_REF void OsclExecSchedulerCommonBase::StartScheduler(OsclSemaphore *aSignal)
→ BeginScheduling(true, false);//blocking, non-native
        if (aSignal)
            aSignal->Signal(); // 在beginScheduling执行完毕之后,AuthorDriver的构造函数就可以退出了
→ OSCL_TRY(err, BlockingLoopL(););  // 这里不会立即返回,要等整个程序停止

→ void OsclExecSchedulerCommonBase::BlockingLoopL() //
    → PVActiveBase* pvtimer = UpdateTimers(waitTicks);
    → PVActiveBase* pvactive = iReadyQ.PopTop();
    → CallRunExec(pvactive);    // OsclActiveObject
OR
    → iReadyQ.Wait(OsclTickCount::TicksToMsec(waitTicks))
    → iExecTimerQ.Pop(pvtimer);
    → CallRunExec(pvtimer);    // OsclTimerObject
OR
    → iReadyQ.Wait();    // Nothing is Ready, 在执行iReadyQ.Add时会调用iSem.Signal()
    → iReadyQ.Signal();

→ void OsclExecSchedulerCommonBase::CallRunExec(PVActiveBase *pvactive)
    → OSCL_TRY_NO_TLS(iErrorTrapImp, err, pvactive->Run(););

iBlockingMode=false

→ OSCL_EXPORT_REF void OsclExecScheduler::RunSchedulerNonBlocking(int32 aCount, int32 &aReady, uint32 &aShortestDelay)
→ BeginScheduling(false, false);//nonblocking, non-native

 

 

代码太多,没时写很多东西,简单的贴点代码吧

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值