real-time embedded multithreading, using threadx and arm ~ chapter11 ~

29
Real-Time Embedded Real-Time Embedded Multithreading, Usin Multithreading, Usin g ThreadX and ARM g ThreadX and ARM ~ Chapter11 ~ ~ Chapter11 ~ 學學 學學 : : 學學 學學 學學學學 學學學學 : : 學學學 學學學

Upload: cara

Post on 04-Jan-2016

69 views

Category:

Documents


5 download

DESCRIPTION

Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~. 學生 : 曾楓喬 指導教授 : 張軒彬. Outline. Introduction Event Flags Group Control Block Summary of Event Flags Group Control Services Sample System Using an Event Flags Group to Synchronize Two Threads - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Real-Time EmbeddedReal-Time EmbeddedMultithreading, Using ThreaMultithreading, Using Threa

dX and ARMdX and ARM~ Chapter11 ~~ Chapter11 ~

學生 學生 : : 曾楓喬曾楓喬指導教授 指導教授 : : 張軒彬張軒彬

Page 2: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

OutlineOutline

IntroductionIntroduction Event Flags Group Control BlockEvent Flags Group Control Block Summary of Event Flags Group Control ServicesSummary of Event Flags Group Control Services Sample System Using an Event Flags Group to Sample System Using an Event Flags Group to

Synchronize Two ThreadsSynchronize Two Threads Event Flags Group InternalsEvent Flags Group Internals

Page 3: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

IntroductionIntroduction

Event flags provide a powerful tool for thread syncEvent flags provide a powerful tool for thread synchronization.hronization.

Each event flag is represented by a single bit.Each event flag is represented by a single bit. Event flags are arranged in groups of 32.Event flags are arranged in groups of 32.

Page 4: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Event Flags Group Control BlockEvent Flags Group Control Block

The characteristics of each event flags group are fouThe characteristics of each event flags group are found in its Control Block.nd in its Control Block.

Page 5: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Summary of Event Flags Group ConSummary of Event Flags Group Control Servicestrol Services

Page 6: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Creating an Event Flags GroupCreating an Event Flags Group

tx_event_flags_createtx_event_flags_create Fig11.4 Attributes of an event flags groupFig11.4 Attributes of an event flags group

When created, all the event flags of a group are iniWhen created, all the event flags of a group are initialized to zero.tialized to zero.

Event Flags Group Control BlockEvent Flags Group Control Block

Event Flags Group nameEvent Flags Group name

Group of 32 one-bit event flagsGroup of 32 one-bit event flags

Page 7: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Creating an Event Flags Group(conCreating an Event Flags Group(cont.)t.)

Page 8: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Setting Event Flags in an Event Setting Event Flags in an Event Flags GroupFlags Group

tx_event_flags_settx_event_flags_set input parameterinput parameter

group_ptrgroup_ptrflags_to_setflags_to_setset_optionset_option

TX_AND -> clearTX_AND -> clear

TX_OR -> setTX_OR -> set The service sets or clears one or more event flaThe service sets or clears one or more event fla

gs in a group.gs in a group.

Page 9: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Setting Event Flags in an Event FlagSetting Event Flags in an Event Flags Group(cont.)s Group(cont.)

Page 10: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Setting Event Flags in an Event FlagSetting Event Flags in an Event Flags Group(cont.)s Group(cont.)

TX_ORTX_OR Current event flags group Value: 0x00Current event flags group Value: 0x00

0000 0000 0000 0000 0000 0000 0000 00000000 0000 0000 0000 0000 0000 0000 0000

Flags to set Value: 0xFF0CFlags to set Value: 0xFF0C

0000 0000 0000 0000 1111 1111 0000 11000000 0000 0000 0000 1111 1111 0000 1100

New current event flags group Value: 0xFF0CNew current event flags group Value: 0xFF0C

0000 0000 0000 0000 1111 1111 0000 11000000 0000 0000 0000 1111 1111 0000 1100

Page 11: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Setting Event Flags in an Event FlagSetting Event Flags in an Event Flags Group(cont.)s Group(cont.)

TX_ANDTX_AND Current event flags group Value: 0xFF0CCurrent event flags group Value: 0xFF0C

0000 0000 0000 0000 1111 1111 0000 11000000 0000 0000 0000 1111 1111 0000 1100

Flags to set Value: 0x111Flags to set Value: 0x111

0000 0000 0000 0000 0000 0001 0001 00010000 0000 0000 0000 0000 0001 0001 0001

New current event flags group Value: 0x100New current event flags group Value: 0x100

0000 0000 0000 0000 0000 0001 0000 00000000 0000 0000 0000 0000 0001 0000 0000

Page 12: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Setting Event Flags in an Event FlagSetting Event Flags in an Event Flags Group(cont.)s Group(cont.)

Page 13: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Getting Event Flags from an Event FGetting Event Flags from an Event Flags Grouplags Group

tx_event_flags_gettx_event_flags_get input parameterinput parameter

group_ptrgroup_ptr

requested_flagsrequested_flags

get_optionget_option

TX_AND TX_AND_CLEARTX_AND TX_AND_CLEAR

TX_OR TX_OR_CLEARTX_OR TX_OR_CLEAR

wait_optionwait_option The service “gets”, or waits on event flags from an evThe service “gets”, or waits on event flags from an ev

ent flags group.ent flags group.

Page 14: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Getting Event Flags from an Event FGetting Event Flags from an Event Flags Group(cont.)lags Group(cont.)

Page 15: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Getting Event Flags from an Event FGetting Event Flags from an Event Flags Group(cont.)lags Group(cont.)

TX_AND_CLEARTX_AND_CLEAR Current event flags group Value: 0x537Current event flags group Value: 0x537

0000 0000 0000 0000 0000 0101 0011 01110000 0000 0000 0000 0000 0101 0011 0111

Flags to get Value: 0x111Flags to get Value: 0x111

0000 0000 0000 0000 0000 0001 0001 00010000 0000 0000 0000 0000 0001 0001 0001

New current event flags group Value: 0x426New current event flags group Value: 0x426

0000 0000 0000 0000 0000 0100 0010 01100000 0000 0000 0000 0000 0100 0010 0110

Page 16: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Getting Event Flags from an Event FGetting Event Flags from an Event Flags Group(cont.)lags Group(cont.)

Page 17: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Deleting an Event Flags GroupDeleting an Event Flags Group

tx_event_flags_deletetx_event_flags_delete input parameterinput parameter

group_ptrgroup_ptr The service deletes an event flags group.The service deletes an event flags group. When a group is deleted , all threads suspended When a group is deleted , all threads suspended

on it resume and receive a on it resume and receive a TX_DELETEDTX_DELETED..

Page 18: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Deleting an Event Flags Group(conDeleting an Event Flags Group(cont.)t.)

Page 19: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Retrieving Information about an EveRetrieving Information about an Event Flags Groupnt Flags Group

tx_event_flags_info_gettx_event_flags_info_get input parameterinput parameter

group_ptrgroup_ptr output parametersoutput parameters

current_flagscurrent_flagsfirst_suspendedfirst_suspendedsuspended_countsuspended_countnext_groupnext_group

The service retrieves several useful items of informatiThe service retrieves several useful items of information about an event flags group.on about an event flags group.

Page 20: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Retrieving Information about an EveRetrieving Information about an Event Flags Group(cont.)nt Flags Group(cont.)

Page 21: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Retrieving Information about an EveRetrieving Information about an Event Flags Group(cont.)nt Flags Group(cont.)

Page 22: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Sample System Using an Event Flags GrSample System Using an Event Flags Group to Synchronize Two Threadsoup to Synchronize Two Threads

Page 23: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Sample System Using an Event Flags GrSample System Using an Event Flags Group to Synchronize Two Threads(cont.)oup to Synchronize Two Threads(cont.)

Page 24: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Sample System Using an Event Flags GrSample System Using an Event Flags Group to Synchronize Two Threads(cont.)oup to Synchronize Two Threads(cont.)

Page 25: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Sample System Using an Event Flags GrSample System Using an Event Flags Group to Synchronize Two Threads(cont.)oup to Synchronize Two Threads(cont.)

Page 26: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Sample System Using an Event Flags GrSample System Using an Event Flags Group to Synchronize Two Threads(cont.)oup to Synchronize Two Threads(cont.)

Page 27: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Sample System Using an Event Flags GrSample System Using an Event Flags Group to Synchronize Two Threads(cont.)oup to Synchronize Two Threads(cont.)

Page 28: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

Event Flags Group InternalsEvent Flags Group Internals

Page 29: Real-Time Embedded Multithreading, Using ThreadX and ARM ~ Chapter11 ~

THE ENDTHE END