1 / 16

VDM-RT Scheduling in Overture

VDM-RT Scheduling in Overture. Kenneth Lausdahl and Peter Gorm Larsen. Scheduling. Controls the available resources CPUs BUSses Deployment of instances of classes to cpus Inter-cpu communication implicitly over busses Schedule resources Advances time in time slices

gezana
Download Presentation

VDM-RT Scheduling in Overture

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. VDM-RT Scheduling in Overture Kenneth Lausdahl and Peter Gorm Larsen VDM-RT Scheduling

  2. Scheduling Controls the available resources CPUs BUSses Deployment of instances of classes to cpus Inter-cpu communication implicitly over busses Schedule resources Advances time in time slices Always determines minimum time slice to advance VDM-RT Scheduling 2

  3. Resources There is only one master scheduler Master scheduler is able to advance wall time VDM-RT Scheduling 3

  4. A Small Example system S instance variables cpu1 : CPU := new CPU(<FCFS>, 1E9); cpu2 : CPU := new CPU(<FCFS>, 1E9); static public a : A := new A(); static public b : B := new B(); operations public S: () ==> S S() == (cpu1.deploy(a); cpu2.deploy(b)) end S class Test operations public Run:() ==> nat * nat Run() == (start(S`a); start(S`b); return mk_(S`a.GetA(), S`b.GetB())) end Test class A instance variables a: nat := 0 operations public IncA: () ==> () IncA() == duration(6) a := a + 1; public GetA: () ==> nat GetA() == duration (10) (return a); sync per GetA => #fin(IncA) >= 1; mutex(IncA,GetA); thread for i = 1 to 3 do IncA() end A VDM-RT Scheduling 4

  5. Architecture BUS Resources CPU1 CPU2 vCPU Threads Threads Threads Policy Policy Policy … B A VDM-RT Scheduling 5

  6. Thread life cycle CREATED TIMESTEP Swap in/out RUNABLE • RUNABLE • Commit values from last run Swap in/out RUNNING RUNNING COMPLETED Swap out, kill Thread Policy controlsSwap VDM-RT Scheduling VDM-RT Scheduling 6 6 TIVDM2

  7. Schedule resource Resource Scheduler • Reschedule resource • Get thread through policy • Thread run time slice • RUNNING • If duration TIMESTEP • Else RUNABLE CPU1 Policy Threads CPU2 vCPU Threads Threads Policy Policy A … B Reschedule Reschedule VDM-RT Scheduling 7

  8. Time step size Cpu2 Cpu1 Time step size decided per thread in RUNNING stage Resource Scheduler uses smallest time step calculated over all resources. VDM-RT Scheduling

  9. Thread schedule on different cpus • A • i = 0 • RUNABLE • A • i = 0 • RUNNING • A • i = 0 • TIMESTEP(6) • A • i = 0 • TIMESTEP(4) • A • i = 0 • TIMESTEP(2) • A • i = 0 -> i = 1 • Committing last transaction • RUNNING … • B • i = 0 • RUNABLE • Reschedule • Time Step = 0 • B • i = 0 • RUNNING Reschedule • B • i = 0 • TIMESTEP(2) • B • i = 0 -> i = 1 • Committing last transaction • RUNNING Advance wall time.Time Step = min(2 ; 6) = 2 Reschedule • B • i = 1 • TIMESTEP(2) • B • i = 0 -> i = 2 • Committing last transaction • RUNNING Advance wall time.Time Step = min(2 ; 4) = 2 Reschedule • B • i = 2 • TIMESTEP(2) Advance wall time.Time Step = min(2 ; 2) = 2 • B • i = 0 -> i = 3 • Committing last transaction • RUNNING • B • i = 3 • COMPLETED … CPU1 CPU2 Scheduler VDM-RT Scheduling

  10. Thread schedule on the same cpu • A • i = 0 • RUNABLE • A • i = 0 • RUNNING • A • i = 0 • TIMESTEP(6) • A • i = 0 -> i = 1 • Committing last transaction • RUNNING … • Reschedule • Time Step = 0 • B • i = 0 • RUNABLE • B • i = 1 • RUNNING Compute thread in B Compute thread in A Compute thread in B Compute thread in B • B • i = 1 • TIMESTEP(2) Swap in thread A Advance wall time.Swap time Swap out thread A • B • i = 1 -> i = 2 • Committing last transaction • RUNNING Advance wall time.Swap time Swap in thread B Advance wall time.Swap time • B • i = 2 • TIMESTEP(2) • B • i = 2-> i = 3 • Committing last transaction • RUNNING Advance wall time.Time Step = 6 Advance wall time.Time Step = 12 Advance wall time.Time Step = 8 Advance wall time.Time Step = 10 Reschedule • B • i = 3 • TIMESTEP(2) • B • i = 3 -> i = 4 • Committing last transaction • RUNNING • B • i = 4 • COMPLETED … Both on CPU1 Scheduler VDM-RT Scheduling

  11. Scheduling Resources When the debug thread completes the execution is terminated. If all resources (CPUs and BUSes) are idle the model has deadlocked. VDM-RT Scheduling 11

  12. Reschedule CPUResource if (policy.reschedule()){ SchedulableThread best = policy.getThread(); if (running != best) // We swapped { If (running != null) RTLogger.log("ThreadSwapOut...); if (delayed) RTLogger.log("DelayedThreadSwapIn...); else RTLogger.log("ThreadSwapIn...); } running = best; running.runslice(policy.getTimeslice()); if (running.getRunState() == RunState.COMPLETE) { RTLogger.log("ThreadSwapOut...); RTLogger.log("ThreadKill...); running = null; } … • Reschedule of a CPU • VDM-RT Log • ThreadCreate • ThreadSwapIn • DelayedThreadSwapIn • ThreadSwapOut • ThreadKill… • Request • Activation • Completion • Of ops + messages VDM-RT Scheduling 12

  13. Threads @Override publicvoid run() { reschedule(); body(); setState(COMPLETE); resource.unregister(this); synchronized (allThreads) { allThreads.remove(this); } } abstract protected void body(); • One virtual thread (the debug thread) exists where duration is skipped. • All threads are implemented on top of Java threads • The abstract body will handle the actual execution of the thread. VDM-RT Scheduling 13

  14. Computation Step • public void step() • { • if (dialect is VDM_RT) • { • if (!virtual) // vCPUs don't take any time • duration(Properties.rt_duration_default); • } • else • SystemClock.advance(Properties.rt_duration_default); • if (++steps >= timeslice) • { • reschedule(); • steps = 0; • } • } When executing a computation step is taken before a time penalty is taken All Expressions and Statements have a default duration Can be overruled by cycle- and duration- statements VDM-RT Scheduling 14

  15. Async Operation Calls becomesThreads • Async operation calls on a different CPU goes over a BUS • Threads gets the parameter values through a message queue. • Gets parameter values as MessageRequest from BUS • Normal operation returns results as MessageResponse in the same BUS VDM-RT Scheduling 15

  16. BUS • Operation calls through a BUS • MessageRequest – ready to communicate • MessaggeActivate – Send the parameter values • MessageFinish – Take size of message into account in time penalty • MessageResponse – get the result • Data holder + ControlQueue • ControlQueue • A queue where threads can wait to get access • Block calls the waiting method of SchedulableThread • Get cannot complete before a reschedule • When guard potentially changes all threads are notified to recheck their blocked guards are now satisfied. VDM-RT Scheduling 16

More Related