Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
PolyORB-HI-C
Commits
dce0a6f3
Unverified
Commit
dce0a6f3
authored
Nov 07, 2019
by
Jerome Hugues
Committed by
GitHub
Nov 07, 2019
Browse files
Merge pull request #33 from bouazizrahma/extend_gqueue
extend gqueue and types packages to support dispatch pattern from BA …
parents
8846ef04
d9f22c65
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/po_hi_gqueue.h
View file @
dce0a6f3
...
...
@@ -130,6 +130,42 @@ int __po_hi_gqueue_next_value(__po_hi_task_id id,
int
__po_hi_gqueue_get_count
(
__po_hi_task_id
id
,
__po_hi_local_port_t
port
);
/**
* \brief Compute dispatch condition :
* return 1 when the condition of one of the transitions that stemmed from the next
* complete state is verified (i.e. all its dispatch triggers received events on
* their corresponding ports) else return 0.
* It also sets the index of the transition to execute according to the condition that is
* verified.
*
* \param id thread identifier in the local process.
* \param next_complete_state the struct that contains arrays informations about
* transitions and dispatch triggers of the next complete state.
* \param initial_sizes_of_dispatch_triggers_of_all_transitions array that contains the number of
* events that are pending each dispatch ports of all transitions.
* \param index_transition_to_execute the index of transition to execute,
* this parameter will be set according to the transition whose condition is verified.
*/
__po_hi_bool_t
__po_hi_gqueue_compute_index_transition_to_execute
(
__po_hi_task_id
id
,
__po_hi_ba_automata_state_t
*
next_complete_state
,
int
*
initial_sizes_of_dispatch_triggers_of_all_transitions
,
__po_hi_int32_t
*
index_transition_to_execute
);
/**
* \brief Wait until all the specified dispatch events (according to the next complete state)
* are received on the corresponding ports for a given thread.
*
* \param id thread identifier in the local process.
* \param next_complete_state the struct that contains arrays informations about
* transitions and dispatch triggers of the next complete state.
* \param index_transition_to_execute the index of transition to execute,
* this parameter will be set according to the transition whose condition is verified.
*/
void
__po_hi_gqueue_wait_for_specific_incoming_events
(
__po_hi_task_id
id
,
__po_hi_ba_automata_state_t
*
next_complete_state
,
__po_hi_int32_t
*
index_transition_to_execute
);
/**
* \brief Wait until an event is received on any port for a given thread.
*
...
...
include/po_hi_types.h
View file @
dce0a6f3
...
...
@@ -104,6 +104,31 @@ typedef enum
__PO_HI_INVALID_PORT_KIND
=
50
}
__po_hi_port_kind_t
;
typedef
enum
{
__po_hi_initial
,
__po_hi_initial_complete
,
__po_hi_initial_complete_final
,
__po_hi_initial_final
,
__po_hi_complete
,
__po_hi_complete_final
,
__po_hi_final
,
__po_hi_execution
}
__po_hi_state_kind_t
;
typedef
struct
{
__po_hi_int32_t
nb_transitions
;
__po_hi_int32_t
*
nb_dispatch_triggers_of_each_transition
;
__po_hi_int32_t
*
dispatch_triggers_of_all_transitions
;
__po_hi_int32_t
nb_of_all_dispatch_events
;
}
__po_hi_ba_automata_state_t
;
void
__po_hi_copy_array
(
void
*
dst
,
void
*
src
,
__po_hi_uint32_t
size
);
#endif
/* __PO_HI_TYPES_H_ */
src/po_hi_gqueue.c
View file @
dce0a6f3
...
...
@@ -417,6 +417,89 @@ __po_hi_port_id_t __po_hi_gqueue_store_in (__po_hi_task_id id,
return
__PO_HI_SUCCESS
;
}
/******************************************************************************/
__po_hi_bool_t
__po_hi_gqueue_compute_index_transition_to_execute
(
__po_hi_task_id
id
,
__po_hi_ba_automata_state_t
*
next_complete_state
,
int
*
initial_sizes_of_dispatch_triggers_of_all_transitions
,
__po_hi_int32_t
*
index_transition_to_execute
)
{
__po_hi_int32_t
i
=
0
;
__po_hi_bool_t
dispatch_condition_of_any_transition_is_verified
=
0
;
__po_hi_int32_t
tmp
=
0
;
__po_hi_int32_t
j
=
0
;
__po_hi_bool_t
dispatch_condition
;
while
(
i
<
next_complete_state
->
nb_transitions
&&
!
dispatch_condition_of_any_transition_is_verified
)
{
dispatch_condition
=
1
;
while
(
j
<
(
tmp
+
next_complete_state
->
nb_dispatch_triggers_of_each_transition
[
i
])
&&
dispatch_condition
)
{
dispatch_condition
=
(
initial_sizes_of_dispatch_triggers_of_all_transitions
[
j
]
<
__po_hi_gqueue_get_count
(
id
,
next_complete_state
->
dispatch_triggers_of_all_transitions
[
j
]));
j
++
;
}
if
(
dispatch_condition
)
{
*
index_transition_to_execute
=
i
+
1
;
}
tmp
=
tmp
+
next_complete_state
->
nb_dispatch_triggers_of_each_transition
[
i
];
j
=
tmp
;
dispatch_condition_of_any_transition_is_verified
=
dispatch_condition
;
i
++
;
}
return
dispatch_condition
;
}
/******************************************************************************/
void
__po_hi_gqueue_wait_for_specific_incoming_events
(
__po_hi_task_id
id
,
__po_hi_ba_automata_state_t
*
next_complete_state
,
__po_hi_int32_t
*
index_transition_to_execute
)
{
/* Locking only the mutex of the semaphore */
int
result
=
__po_hi_sem_mutex_wait_gqueue
(
__po_hi_gqueues_semaphores
,
id
);
__DEBUGMSG
(
"GQUEUE_SEM_MUTEX_WAIT %d %d
\n
"
,
id
,
result
);
assert
(
result
==
__PO_HI_SUCCESS
);
int
initial_sizes_of_dispatch_triggers_of_all_transitions
[
next_complete_state
->
nb_of_all_dispatch_events
];
for
(
int
i
=
0
;
i
<
(
next_complete_state
->
nb_of_all_dispatch_events
);
i
++
)
{
initial_sizes_of_dispatch_triggers_of_all_transitions
[
i
]
=
__po_hi_gqueue_get_count
(
id
,
next_complete_state
->
dispatch_triggers_of_all_transitions
[
i
]);
}
*
index_transition_to_execute
=
-
1
;
while
(
!
__po_hi_gqueue_compute_index_transition_to_execute
(
id
,
next_complete_state
,
initial_sizes_of_dispatch_triggers_of_all_transitions
,
index_transition_to_execute
))
{
__PO_HI_INSTRUMENTATION_VCD_WRITE
(
"0t%d
\n
"
,
id
);
/* Telling the semaphore to wait with putting its condvar on wait mode */
int
res_sem
=
__po_hi_sem_wait_gqueue
(
__po_hi_gqueues_semaphores
,
id
);
__DEBUGMSG
(
"GQUEUE_SEM_WAIT %d %d
\n
"
,
id
,
res_sem
);
assert
(
res_sem
==
__PO_HI_SUCCESS
);
__PO_HI_INSTRUMENTATION_VCD_WRITE
(
"1t%d
\n
"
,
id
);
}
#if defined (MONITORING)
record_event
(
SPORADIC
,
WAIT_FOR
,
id
,
invalid_port_t
,
invalid_port_t
,
*
port
,
invalid_local_port_t
,
NULL
);
#endif
/** Releasing only the mutex of the semaphore*/
int
res
=
__po_hi_sem_mutex_release_gqueue
(
__po_hi_gqueues_semaphores
,
id
);
__DEBUGMSG
(
"GQUEUE_SEM_MTUEX_RELEASE %d %d
\n
"
,
id
,
res
);
assert
(
res
==
__PO_HI_SUCCESS
);
#ifdef __PO_HI_GQUEUE_ASSERTIONS
__DEBUGMSG
(
"
\n
The task queue must be considered not empty "
);
#endif
}
/******************************************************************************/
void
__po_hi_gqueue_wait_for_incoming_event
(
__po_hi_task_id
id
,
__po_hi_local_port_t
*
port
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment