Försättsblad till skriftlig tentamen vid Linköpings Universitet

advertisement

Försättsblad till skriftlig

tentamen vid Linköpings Universitet

(fylls i av ansvarig)

Datum för tentamen 2014-06-04

Sal

Tid 08:00 – 12:00

Kurskod

TDDI11

DAT1

Programmering av inbyggda system

Provkod

Kursnamn/benämning

Institution

Antal uppgifter som ingår i tentamen

Antal sidor på tentamen

(inkl. försättsbladet)

Jour/Kursansvarig

Telefon under skrivtid

Besöker salen ca kl.

Kursadministratör

(namn + tfnnr + mailadress)

Tillåtna hjälpmedel

Övrigt

( exempel när resultat kan ses på webben, betygsgränser, visning,

övriga salar tentan går i m.m.)

Vilken typ av papper ska användas, rutigt eller linjerat

Antal exemplar i påsen

IDA

11 questions for 40 points

7 pages

Unmesh Bordoloi

+46 13 28 5628

About one hour after exam start

Madeleine Häger Dahlqvist madeleine.

dahlqvist @liu.se

Precise, cleanly written and clearly motivated assumptions, statements and reasoning raise the impression and are required for highest score. If in doubt, state clearly your interpretation of the question, your assumptions, and answer according to that.

Answer Question 1 to Question 10 on paper. Question 11 should be answered in your computer.

Answer Question 1 to Question 10 on paper. For Question 11, answer in your computer in a given file called exam.c. Further instructions on this are given in Question 11.

Question 1. ( 2 points)

When we develop software for general-purpose systems, it is often enough to make sure that the software is functionally correct. However, embedded systems must also satisfy non-functional properties. Give four examples of non-functional properties.

Question 2. (2 points)

Polling or programmed I/O is not considered favorably because it results in a lot of wasted cycles. Yet, in some embedded systems, it turns out to be a good choice. Why?

Question 3. (4 points)

Most embedded systems must interact with the environment. However, embedded systems understand digital signals whereas the environment deals with analog signals. How is this problem addressed?

Question 4. (2 points)

Is C a good choice of programming language for embedded systems?

Give two reasons to support your answer.

Question 5. (4 points)

Explain the foreground/background system. Draw a figure, if necessary. Mention the advantages and disadvantages of this system.

Question 6. (4 points)

Embedded systems design often follows the Y-chart design methodology. Below we illustrate the Y-chart but three boxes are left empty. Fill in the boxes and explain the methodology.

 

Question 7. (2 points)

Explain a situation where two threads require mutual exclusion by means of a mutex.

Question 8.

(a) A task set contains 3 tasks. Their execution times and periods are given as follows. Ci denotes execution times and Ti denotes periods. The periods are equal to the deadlines. Is this task set schedulable under the Earliest Deadline First (EDF) scheduling policy? Use the utilization based approach to answer the question. (2 points)

Ci Ti

1 4

2 6

3 8

(b) Draw the EDF schedule for the 3 tasks. (2 points)

Question 9.

An electronic lock controlling entry to a door is one example of an embedded system. You may have seen similar locks, in black box next to restricted-entry doors at our university, with keys labeled 0 to 9. We’re going to take a simpler keypad comprising just two keys, “0” and “1”. The binary keypad provides inputs S to the Finite State Machine which must decide whether the correct input sequence of 0s and 1s has been entered. You are told that the entry code is the 4-bit sequence “0110”. If this sequence has been correctly input to the FSM, then the FSM moves into its end-state where it outputs a “1” (i.e., the “open” command) to the release mechanism. Any incorrect sequence outputs a “0” which means “do not open”.

A partial Moore Finite State Machine is shown in the figure below. It shows all the states but only some of the transitions.

You should complete the FSM. a.

Draw all the transitions and label them with the proper inputs.

(2 points) b.

Mark the initial and the final states. (2 points) c.

Write the output in each state. (2 points)

Question 10.

You are given a function below. If you want you can use your computer but you must write the answer in paper.

#include <stdbool.h> bool magic(){ union {

int integer;

char singleByte;

} magicTest; magicTest.integer = 1; return magicTest.singleByte;

} a.

Does this function return the same result on all machines? When does it return false and when does it return true? (2 points)

b. Explain why the function works correctly. (3 points)

Question 11. (5 points)

Write a function that swaps odd and even bits in an integer. (e.g., bit 0 and bit 1 are swapped, bit 2 and bit 3 are swapped etc.)

Right-click the desktop to start a terminal and the communication client. Copy “exam.c” from the read-only given_files

folder and open your read-write copy: cd ; cp given_files/exam.c exam.c emacs exam.c &

The body of the swap(int) function is empty. You must complete this function in your computer as the answer to this question. Do not change the main() function in the file.

It is mandatory to explain your approach to solve the problem. This explanation should be included in the function swap(int) in exam.c in form of comments. You will get partial credits if your program is wrong but explanation is correct.

Download