EM-ODP  3.7.0
Event Machine on ODP
event_machine_scheduler.c
1 /*
2  * Copyright (c) 2015-2023, Nokia Solutions and Networks
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * * Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived
16  * from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #include "em_include.h"
32 
33 void
35 {
36  em_locm_t *const locm = &em_locm;
37 
39  locm->event_burst_cnt)
40  return;
41 
42  const queue_elem_t *q_elem = locm->current.sched_q_elem;
43 
44  if (unlikely(!q_elem || q_elem->type != EM_QUEUE_TYPE_ATOMIC))
45  return;
46 
47  if (q_elem->flags.in_atomic_group)
48  atomic_group_release();
49  else
50  odp_schedule_release_atomic();
51 
52  /*
53  * Mark that em_atomic_processing_end() has been called
54  * for the current atomic context.
55  */
57 }
58 
59 void
61 {
62  em_locm_t *const locm = &em_locm;
63 
65  locm->event_burst_cnt)
66  return;
67 
68  const queue_elem_t *q_elem = locm->current.sched_q_elem;
69 
70  if (unlikely(!q_elem || q_elem->type != EM_QUEUE_TYPE_PARALLEL_ORDERED))
71  return;
72 
73  odp_schedule_release_ordered();
74  /*
75  * ODP might not actually release the ordered context here. From an EM
76  * point of view the context needs to be ended since the ODP result is
77  * unknown.
78  */
80 }
81 
82 void
84 {
85  odp_schedule_prefetch(1);
86 }
87 
90 {
91  const em_locm_t *const locm = &em_locm;
92 
93  if (locm->current.sched_q_elem == NULL) {
94  if (queue != NULL)
95  *queue = EM_QUEUE_UNDEF;
97  }
98 
99  if (queue != NULL)
100  *queue = (em_queue_t)(uintptr_t)locm->current.sched_q_elem->queue;
101 
102  return locm->current.sched_context_type;
103 }
ODP_PACKED::sched_context_type
em_sched_context_type_t sched_context_type
Definition: em_mem.h:170
em_ordered_processing_end
void em_ordered_processing_end(void)
Definition: event_machine_scheduler.c:60
queue_elem_t::type
uint8_t type
Definition: em_queue_types.h:216
em_locm
ENV_LOCAL em_locm_t em_locm
em_atomic_processing_end
void em_atomic_processing_end(void)
Definition: event_machine_scheduler.c:34
ODP_PACKED::sched_q_elem
queue_elem_t * sched_q_elem
Definition: em_mem.h:176
em_locm_t::current
em_locm_current_t current
Definition: em_mem.h:190
EM_QUEUE_TYPE_ATOMIC
@ EM_QUEUE_TYPE_ATOMIC
Definition: event_machine_hw_types.h:112
em_locm_t::event_burst_cnt
int event_burst_cnt
Definition: em_mem.h:198
queue_elem_t::queue
uint32_t queue
Definition: em_queue_types.h:225
em_preschedule
void em_preschedule(void)
Definition: event_machine_scheduler.c:83
em_sched_context_type_current
em_sched_context_type_t em_sched_context_type_current(em_queue_t *queue)
Definition: event_machine_scheduler.c:89
queue_elem_t::in_atomic_group
uint8_t in_atomic_group
Definition: em_queue_types.h:201
EM_SCHED_CONTEXT_TYPE_ATOMIC
@ EM_SCHED_CONTEXT_TYPE_ATOMIC
Definition: event_machine_types.h:285
EM_SCHED_CONTEXT_TYPE_ORDERED
@ EM_SCHED_CONTEXT_TYPE_ORDERED
Definition: event_machine_types.h:289
EM_QUEUE_UNDEF
#define EM_QUEUE_UNDEF
Definition: event_machine_types.h:107
em_include.h
EM_QUEUE_TYPE_PARALLEL_ORDERED
@ EM_QUEUE_TYPE_PARALLEL_ORDERED
Definition: event_machine_hw_types.h:122
EM_SCHED_CONTEXT_TYPE_NONE
@ EM_SCHED_CONTEXT_TYPE_NONE
Definition: event_machine_types.h:281
em_locm_t
Definition: em_mem.h:188
queue_elem_t
Definition: em_queue_types.h:180
em_sched_context_type_t
em_sched_context_type_t
Definition: event_machine_types.h:277