DOC PREVIEW
U of U CS 5780 - Embedded System Design Review

This preview shows page 1-2 out of 6 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

ECE/CS 5780/6780: Embedded System DesignChris J. MyersReview 2Chris J. Myers (Review 2)ECE/CS 5780/6780: Embedded System Design1 / 32Chapter 5 TopicsMultithreaded preemptive schedulersSemaphores and their applicationsFixed schedulingChris J. Myers (Review 2)ECE/CS 5780/6780: Embedded System Design2 / 32Chapter 6 TopicsInput captureOutput compareFrequency measurementPulse accumulatorPulse-width modulationChris J. Myers (Review 2)ECE/CS 5780/6780: Embedded System Design3 / 32Chapter 7 TopicsSerial communication basicsSerial communication interface (SCI)Serial peripheral interface (SPI)Chris J. Myers (Review 2)ECE/CS 5780/6780: Embedded System Design4 / 32Chapter 8 TopicsRelays, solenoids, and DC motorsStepper motorsInput switches and keyboardsOutput LEDsLiquid crystal displaysChris J. Myers (Review 2)ECE/CS 5780/6780: Embedded System Design5 / 32Question 1(a)In lab 6, you implemented a thread scheduler in which each thread wouldperiodically attempt to obtain a shared resource which is protected using asemaphore.Assuming that a thread is unable to obtain the semaphore, what should itdo? Briefly, how could you modify the code to do this?Chris J. Myers (Review 2)ECE/CS 5780/6780: Embedded System Design6 / 32Question 1(a)In lab 6, you implemented a thread scheduler in which each thread wouldperiodically attempt to obtain a shared resource which is protected using asemaphore.Assuming that a thread is unable to obtain the semaphore, what should itdo? Briefly, how could you modify the code to do this?ANSWER: It should give up the rest of its time slice. This can be donewith answi. Either point the vector to the scheduler, or have theswihandler jump to the scheduler.Chris J. Myers (Review 2)ECE/CS 5780/6780: Embedded System Design7 / 32Question 1(b)In lab 6, you implemented a thread scheduler in which each thread wouldperiodically attempt to obtain a shared resource which is protected using asemaphore.Explain in words how you could modify the thread scheduler to avoidrescheduling this thread until the semaphore is available.Chris J. Myers (Review 2)ECE/CS 5780/6780: Embedded System Design8 / 32Question 1(b)In lab 6, you implemented a thread scheduler in which each thread wouldperiodically attempt to obtain a shared resource which is protected using asemaphore.Explain in words how you could modify the thread scheduler to avoidrescheduling this thread until the semaphore is available.ANSWER: Keep a blocked list in addition to a runnable list. If a threadwants a locked semaphore, put it on the blocked list. When thesemaphore is released, move a blocked thread to the runnable list.Chris J. Myers (Review 2)ECE/CS 5780/6780: Embedded System Design9 / 32Question 1(c)In lab 6, you implemented a thread scheduler in which each thread wouldperiodically attempt to obtain a shared resource which is protected using asemaphore.Assume that you have modified your scheduler such that threads arescheduled based upon a priority. Explain how priority coupled withspin-lock semaphores can cause a system to deadlock (i.e., stop makinguseful progress).Chris J. Myers (Review 2)ECE/CS 5780/6780: Embedded System Design10 / 32Question 1(c)In lab 6, you implemented a thread scheduler in which each thread wouldperiodically attempt to obtain a shared resource which is protected using asemaphore.Assume that you have modified your scheduler such that threads arescheduled based upon a priority. Explain how priority coupled withspin-lock semaphores can cause a system to deadlock (i.e., stop makinguseful progress).ANSWER: (1) Low priority thread has the semaphore. (2) High prioritythread gets scheduled, and starts to wait on semaphore. (3) Low prioritythread never gets scheduled, and high priority thread cannot move on.Chris J. Myers (Review 2)ECE/CS 5780/6780: Embedded System Design11 / 32Question 1(d)In lab 6, you implemented a thread scheduler in which each thread wouldperiodically attempt to obtain a shared resource which is protected using asemaphore.Adding priority can cause starvation. What is starvation and how doesadding priority cause it?Chris J. Myers (Review 2)ECE/CS 5780/6780: Embedded System Design12 / 32Question 1(d)In lab 6, you implemented a thread scheduler in which each thread wouldperiodically attempt to obtain a shared resource which is protected using asemaphore.Adding priority can cause starvation. What is starvation and how doesadding priority cause it?ANSWER: Starvation is when a thread never gets to make progress. Lowpriority threads can starve if there is always a high priority threadavailable.Chris J. Myers (Review 2)ECE/CS 5780/6780: Embedded System Design13 / 32Question 1(e)In lab 6, you implemented a thread scheduler in which each thread wouldperiodically attempt to obtain a shared resource which is protected using asemaphore.How can you modify a priority scheduler to avoid starvation?Chris J. Myers (Review 2)ECE/CS 5780/6780: Embedded System Design14 / 32Question 1(e)In lab 6, you implemented a thread scheduler in which each thread wouldperiodically attempt to obtain a shared resource which is protected using asemaphore.How can you modify a priority scheduler to avoid starvation?ANSWER: Give low priority threads a bump every time you skip them toget an “effective priority.” After a thread runs, set its effective priority to itsactual priority.Chris J. Myers (Review 2)ECE/CS 5780/6780: Embedded System Design15 / 32Question 2(a)In lab 7, you implemented a device to measure the frequency of a waveform.In this problem, you are to implement a frequency generator. Assume that thedesired frequency is stored in a variable namedfreq.How could the code for generating a square wave shown in Section 6.2.3be modified to generate a desired frequency?Chris J. Myers (Review 2)ECE/CS 5780/6780: Embedded System Design16 / 32Question 2(a)In lab 7, you implemented a device to measure the frequency of a waveform.In this problem, you are to implement a frequency generator. Assume that thedesired frequency is stored in a variable namedfreq.How could the code for generating a square wave shown in Section 6.2.3be modified to generate a desired frequency?ANSWER: In this code,Period= 1/2T. Since T = 1/f, then if yourdesired frequency is f, then you can setPeriodto 1/2f in your maincode.Chris J. Myers (Review 2)ECE/CS 5780/6780: Embedded System Design17 / 32Question 2(b)In lab 7, you implemented a device to measure the frequency of a waveform.In this problem, you are to implement a frequency generator. Assume that


View Full Document

U of U CS 5780 - Embedded System Design Review

Documents in this Course
Lab 1

Lab 1

5 pages

FIFOs

FIFOs

10 pages

FIFOs

FIFOs

5 pages

FIFO’s

FIFO’s

12 pages

MCU Ports

MCU Ports

12 pages

Serial IO

Serial IO

26 pages

Load more
Download Embedded System Design Review
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Embedded System Design Review and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Embedded System Design Review 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?