320 likes | 602 Views
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
E N D
Real-Time EmbeddedMultithreading, 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 • Event Flags Group Internals
Introduction • Event flags provide a powerful tool for thread synchronization. • Each event flag is represented by a single bit. • Event flags are arranged in groups of 32.
Event Flags Group Control Block • The characteristics of each event flags group are found in its Control Block.
Creating an Event Flags Group • tx_event_flags_create • Fig11.4 Attributes of an event flags group • When created, all the event flags of a group are initialized to zero.
Setting Event Flags in an Event Flags Group • tx_event_flags_set • input parameter • group_ptr • flags_to_set • set_option TX_AND -> clear TX_OR -> set • The service sets or clears one or more event flags in a group.
Setting Event Flags in an Event Flags Group(cont.) • TX_OR Current event flags group Value: 0x00 0000 0000 0000 0000 0000 0000 0000 0000 Flags to set Value: 0xFF0C 0000 0000 0000 0000 1111 1111 0000 1100 New current event flags group Value: 0xFF0C 0000 0000 0000 0000 1111 1111 0000 1100
Setting Event Flags in an Event Flags Group(cont.) • TX_AND Current event flags group Value: 0xFF0C 0000 0000 0000 0000 1111 1111 0000 1100 Flags to set Value: 0x111 0000 0000 0000 0000 0000 0001 0001 0001 New current event flags group Value: 0x100 0000 0000 0000 0000 0000 0001 0000 0000
Getting Event Flags from an Event Flags Group • tx_event_flags_get • input parameter • group_ptr • requested_flags • get_option TX_AND TX_AND_CLEAR TX_OR TX_OR_CLEAR • wait_option • The service “gets”, or waits on event flags from an event flags group.
Getting Event Flags from an Event Flags Group(cont.) • TX_AND_CLEAR Current event flags group Value: 0x537 0000 0000 0000 0000 0000 0101 0011 0111 Flags to get Value: 0x111 0000 0000 0000 0000 0000 0001 0001 0001 New current event flags group Value: 0x426 0000 0000 0000 0000 0000 0100 0010 0110
Deleting an Event Flags Group • tx_event_flags_delete • input parameter • group_ptr • The service deletes an event flags group. • When a group is deleted , all threads suspended on it resume and receive a TX_DELETED.
Retrieving Information about an Event Flags Group • tx_event_flags_info_get • input parameter • group_ptr • output parameters • current_flags • first_suspended • suspended_count • next_group • The service retrieves several useful items of information about an event flags group.
Sample System Using an Event Flags Group to Synchronize Two Threads
Sample System Using an Event Flags Group to Synchronize Two Threads(cont.)
Sample System Using an Event Flags Group to Synchronize Two Threads(cont.)
Sample System Using an Event Flags Group to Synchronize Two Threads(cont.)
Sample System Using an Event Flags Group to Synchronize Two Threads(cont.)
Sample System Using an Event Flags Group to Synchronize Two Threads(cont.)