lsli18.4up - 18-118-1Resources and...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 18-118-1Resources and BlockingResourceSomething a task needs that is shared with other tasks.Resource Considered in this Set: Exclusive Access to Shared DataSome tasks may need to write shared data.Some tasks may need to read shared data.Cannot allow one task to read datapartiallyupdated by another.This Set:How programs specify that exclusive access needed.Implications for run time.Protocols to limit worst-case run time.Source: Burns & Wellings, Real-Time Systems and Programming Languages, sec-ond edition. New York: Addison-Wesley, 1997, chapter 13, pp. 399440.18-1EE 4770 Lecture Transparency. Formatted12:10,23 April 1999 from lsli18.18-118-218-2Resource LockingResource NamingHere, resources given names R1, R2,. . .These will refer to memory that can be accessed by multiple tasks.LockingA task that haslockeda resource has exclusive access.(No other task is allowed to read or write it.)Tasks lock a resource when they need to make changes. . .. . .unlockingthe resource after making the changes.Critical RegionThe part of a program that accesses a locked resource.Locking in ProgramsResources locked with alock(RES)call, unlocked with aunlock(RES)call.(Details vary with language, synchronization package, etc.).18-2EE 4770 Lecture Transparency. Formatted12:10,23 April 1999 from lsli18.18-218-318-3Resource Locking Program ExampleConsider a task that updates a table of temperatures:r = readInterface();temp = hf(r);time = gettime();lock(temptable->lock);i = temptable->index++;temptable->tempdata[i] = temp;temptable->timedata[i] = time;unlock(temptable->lock);Betweenlockandunlockis the critical region.Code fragment above locks temptable resource.Table index is incremented and new values written.Without exclusive access, two tasks might write same entry.18-3EE 4770 Lecture Transparency. Formatted12:10,23 April 1999 from lsli18.18-318-418-4System AssumptionsSystems Discussed Here:Computation by tasks (not interrupt handlers).System task-preemptive and uses priority scheduling.Distinct priority levels unless otherwise noted.(That is, no two tasks have same priority.)Interrupt handlers not considered because. . .. . .cannot normally context switch between handlers.18-4EE 4770 Lecture Transparency. Formatted12:10,23 April 1999 from lsli18.18-418-518-5Execution oflockandunlockWhen a task callslock:If resource available, (not locked by another task). . .. . .lockreturns immediately (task continues computing).If resource unavailable, (is locked by another task). . .. . .task moved towaitstate and some other task run....
View Full Document

Page1 / 5

lsli18.4up - 18-118-1Resources and...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online