Exercise 2 SDD - PowerPoint PPT Presentation

1 / 91
About This Presentation
Title:

Exercise 2 SDD

Description:

Exercise 2 SDD – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 92
Provided by: marinal1
Category:
Tags: sdd | exercise | suq

less

Transcript and Presenter's Notes

Title: Exercise 2 SDD


1
  • Exercise 2 SDD
  • Due date 10.12.04
  • The specification should contain the following
  • Class Diagram
  • Component Diagram
  • Statecharts (for some complicated scenarios)
  • Activity Diagrams (for some complicated
    scenarios)
  • Sequence Diagrams (for some complicated
    scenarios)
  • Timing Diagram (for some complicated scenarios)

2
(No Transcript)
3
Exercise can we determine whether the following
tasks are schedulable using RMS?
4
Reminder The RMS Critical Zone Theorem
5
(No Transcript)
6
Utilization bound 3 (2 1/3 - 1)
0.78 Tasks are schedulable!
7
Lecture 6Task Synchronization and Resource
Sharing
8
(No Transcript)
9
(No Transcript)
10
(No Transcript)
11
(No Transcript)
12
(No Transcript)
13
Bounding Priority Inversion
1.
In this case the priority inversion is bounded by
the maximum time a lower priority task can block
a higher priority task.
14
2. Highest Priority Locker
15
3. Priority inheritance protocol
16
(No Transcript)
17
The deadlock problem.
18
(No Transcript)
19
(No Transcript)
20
(No Transcript)
21
(No Transcript)
22
(No Transcript)
23
(No Transcript)
24
(No Transcript)
25
Dekkers algorithm Uses explicit signaling of the
right of the other task to enter its critical
section.
26
  • If class_0 is granted to enter its critical
    section, then claim0 returns true.
  • When class_1 wants to enter its critical section,
    it asks if claim_0 is free and if turn1. If
    claim_0 is free and turn1, then class_1 enters
    the critical section. When class_1 finishes, it
    sets turn0 and claim_1 free.
  • If claim_0 is busy and turn1, then class_1 loops
    and waits for explicit permission.
  • If claim_0 is busy and turn0, then class_1 frees
    claim_1 and will try later again.

27
(No Transcript)
28
  • Spinlocks
  • It is a locking construct in which the calling
    tasks loops iteratively, trying to lock a
    resource.
  • This makes sense only in multiprocessor
    environment, because when the caller spins, it
    burns CPU cycles and does not allow the current
    resource owner to release the semaphore.
  • Usefull when resources are locked for short
    periods, but is overhead when reources are locked
    to long period.
  • Limited spinlock the loop is limited to a
    maximum number of iterations before it gives up
    and becomes blocked.

29
  • Condition Variable
  • Used to synchronize a task, when the task must
    wait for event to occur.
  • A task waits on some condition in a sleeping
    state and is signaled when the predicate
    condition is changed.

30
(No Transcript)
31
If RTOS does not provide condition variables,
they can be implemented
32
  • Barrier
  • Is a conditional variable in which the predicate
    on which the task waits is a specific number of
    tasks that are currently blocked on the condition
    variable.
  • This allows the tasks to meet at some
    synchronization point and continue only when all
    synchronizing tasks are ready.

33
(No Transcript)
34
(No Transcript)
35
Theoretical Analysis
36
(No Transcript)
37
(No Transcript)
38
(No Transcript)
39
It means that 10,000,000 cycles are executed in 1
second.
40
(No Transcript)
41
(No Transcript)
42
(No Transcript)
43
Analysis of aperiodic events
44
  • Ineffective for high-priority, short-deadline
    aperiodic events.
  • The handling of the event is delayed until the
    next polling cycle.

45

46
(No Transcript)
47
(No Transcript)
48
Low Level Programming
49

Hardware Watchdog example Watchdog timer in
VxWorks -Allows C function to be connected to a
specific time delay. -Is invoked as part of the
system clock ISR, meaning that at the systems
clock interrupt level. All restrictions on ISRs
apply to routines connected to watchdog
timer. wdCreate() - create a watchdog
timerwdDelete() - delete a watchdog
timer wdStart() - start a watchdog
timerwdCancel() - cancel a currently counting
watchdog
50
In the fragment below, if maybeSlowRoutine( )
takes more than 60 ticks, logMsg() will be called
with the string as a parameter, causing the
message to be printed on the console. Normally,
of course, more significant corrective action
would be taken. WDOG_ID wid wdCreate ()
wdStart (wid, 60, logMsg, "Help, I've timed
out!") maybeSlowRoutine () / user-supplied
routine / wdCancel (wid)
51
Software Watchdog example
void WdClassInit() taskSpawn( "tLX",
/ task name /
WD_LO_TASK_PRIORITY, / task priority /
NULL, / task option word
/ WD_TASK_STACK_SIZE, / stack size
(bytes) / WdTaskFnGW, / task
entry point / 0,0,0,0,0,0,0,0,0,0 )
/ optional params / taskSpawn( "tHX",
/ task name /
WD_LO_TASK_PRIORITY, / task priority /
NULL, / task option word
/ WD_TASK_STACK_SIZE, / stack size
(bytes) / WdTaskFnGW, / task
entry point / 0,0,0,0,0,0,0,0,0,0 )
/ optional params /
52
Software Watchdog example
STATUS WdClassWdTaskFnGW( ) return (
(this)-gtWdTaskFn() )
53
Software Watchdog example
STATUS WdClassWdTaskFn() while ( true
) taskDelay( 2SECOND ) // Wait between
cycles // Check if low priority task got cpu
in last 'sw_wd_timeout_' seconds UINT32 now
tickGet() UINT32 delta (now -
low_pr_task_act_time)/sysClkRateGet() if( delta
gt sw_wd_timeout_ ) logMsg(Help, Ive timed
out!) taskDelay( SECOND ) UINT32 now
tickGet() low_pr_task_act_time now
54
Software Watchdog example
SysInit() WdClass software_watchdog sof
tware_watchdog-gtInit()
55
(No Transcript)
56
(No Transcript)
57
(No Transcript)
58
(No Transcript)
59
(No Transcript)
60
(No Transcript)
61
(No Transcript)
62
(No Transcript)
63
(No Transcript)
64
(No Transcript)
65
(No Transcript)
66
(No Transcript)
67
(No Transcript)
68
(No Transcript)
69
(No Transcript)
70
(No Transcript)
71
(No Transcript)
72
  • Different methods are used for controlling when
    interrupts occur.
  • The following mechanisms are used to ensure that
    interrupts are handled in the correct order
  • status-word-control device or program status
    word that enables /disables interrupts of
    particular devices.
  • mask control bit mask control indicates which
    interrupts can be handled and which ones
    are blocked.
  • level control processor interrupt level
    indicates that devices of higher level
    may interrupt.

73
(No Transcript)
74
  • Architectural design of device I/O drivers
  • Contents
  • Mutual Exclusion for Device Access
  • Synchronous I/O model
  • Asynchronous I/O model
  • Latest Input only driver
  • Simple Asynchronous Output Driver
  • Double-Buffered Input Data Driver
  • Serial Input Data Spooler Driver
  • Zero Copy DMA Input Spooler Driver
  • Printer (Output) Spooler Driver

75
(No Transcript)
76
  • Device driver may ensure use by no more than one
    task at a time.
  • Use Mutex, semaphore or message queue.
  • Example mutual exclusion for single device write
    operation.
  • -Dev_Init() calls to sm_create() and sets initial
    value of semaphore to available.
  • -Dev_Write() calls to sm_take() before the access
    to device.
  • -Dev_Write() call to sm_give() after access to
    device.

77
  • Example 1 Synchronous I/O Model
  • Calling task is blocked until I/O transaction is
    completed. All the other tasks or ISRs may
    execute.
  • READ_OPERATION
    DEVICE_ISR
  • BEGIN BEGIN
  • StartIODeviceOperation() HandleHardwareData()
  • semTake() semGive()
  • //wait for a signal //signal completion
  • GetDeviceData END
  • END

78
  • Example 2 Asynchronous I/O Model
  • Calling task is not blocked while I/O is taking
    place.
  • READ_OPERATION
    DEVICE_ISR
  • BEGIN BEGIN
  • Rcq_recv(D_IN, WAIT ) TransferData
  • StartNextInputOperation q_send(D_IN)
  • Process D_IN data //send new data
  • END END

79
  • Example 3 Free Running Asynchronous Input
  • Calling task is not blocked while I/O is taking
    place. But hardware can deliver inputs repeatedly
    without software request.
  • READ_OPERATION
    DEVICE_ISR
  • BEGIN BEGIN
  • Rcq_recv(D_IN, NOWAIT ) TransferData
  • Process D_IN data q_send(D_IN)
  • //send new data
  • END END

80
  • Example 4 Handling Latest Input Only
  • In previous examples an old data is taken. A data
    can be queued up and become very old.
  • To solve we use protected shared data area.
  • Protected shared data protects from access
    collisions using a Binary Semaphore.
  • Data Area contains latest measured data only. Old
    data is overwritten.
  • Input device hardware can be free running, giving
    interrupts whenever ready.

81
sem_take(mysm,SM_WAIT) Read data from shared
data area End access Sem_give(mysm)
/new data is available/ sem_take(mysm,SM_NOWAIT)
If semaphore OK, Write to shared data
area End access sem_give(mysm_ Else EndIF
82
  • Example 5 Double Buffered Input Data
  • One buffer being filled while the other being
    processed.
  • Works OK if buffer processing completes before a
    new buffer is filled.

83
  • Example 6 Serial Input Data Spooler
  • Characters arrive via individual interrupts.

Get next message( q_receive() )
Return the buffer( pt_retbuf() )
Queue this message ( q_send() ) Request new
buffer(pt_getbuf(NOWAIT))
84
  • Example 6 Zero Copy DMA Input Spooler
  • Direct DMA interface to transfer data directly

/Interrupt current buffer full/
Get next message( q_receive() )
Send message ( q_send() ) Request new
buffer(pt_getbuf(NOWAIT)) Direct DMA interface to
new buffer
Return data block( de_read() )
Return the buffer( pt_retbuf() )
85
(No Transcript)
86
(No Transcript)
87
(No Transcript)
88
(No Transcript)
89
(No Transcript)
90
(No Transcript)
91
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com