EM-ODP 4.4.0
Event Machine on ODP
Loading...
Searching...
No Matches
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#ifndef _GNU_SOURCE
32#define _GNU_SOURCE
33#endif
34
35#ifdef HAVE_CONFIG_H
36#include "config.h"
37#endif
38
39#include <stdint.h>
40
41#include <odp_api.h>
42
43#include <event_machine.h>
44
45#include "em_atomic_group.h"
46#include "em_mem.h"
47#include "em_queue_types.h"
48
49void
51{
52 em_locm_t *const locm = &em_locm;
53
55 locm->event_burst_cnt)
56 return;
57
58 const queue_elem_t *q_elem = locm->current.sched_q_elem;
59
60 if (unlikely(!q_elem || q_elem->type != EM_QUEUE_TYPE_ATOMIC))
61 return;
62
63 if (q_elem->flags.in_atomic_group)
64 atomic_group_release();
65 else
66 odp_schedule_release_atomic();
67
68 /*
69 * Mark that em_atomic_processing_end() has been called
70 * for the current atomic context.
71 */
73}
74
75void
77{
78 em_locm_t *const locm = &em_locm;
79
81 locm->event_burst_cnt)
82 return;
83
84 const queue_elem_t *q_elem = locm->current.sched_q_elem;
85
86 if (unlikely(!q_elem || q_elem->type != EM_QUEUE_TYPE_ORDERED))
87 return;
88
89 odp_schedule_release_ordered();
90 /*
91 * ODP might not actually release the ordered context here. From an EM
92 * point of view the context needs to be ended since the ODP result is
93 * unknown.
94 */
96}
97
98void
100{
101 odp_schedule_prefetch(1);
102}
103
106{
107 const em_locm_t *const locm = &em_locm;
108
109 if (locm->current.sched_q_elem == NULL) {
110 if (queue != NULL)
111 *queue = EM_QUEUE_UNDEF;
113 }
114
115 if (queue != NULL)
116 *queue = (em_queue_t)(uintptr_t)locm->current.sched_q_elem->queue;
117
118 return locm->current.sched_context_type;
119}
ENV_LOCAL em_locm_t em_locm
#define EM_QUEUE_UNDEF
@ EM_QUEUE_TYPE_ORDERED
@ EM_QUEUE_TYPE_ATOMIC
void em_ordered_processing_end(void)
em_sched_context_type_t em_sched_context_type_current(em_queue_t *queue)
void em_preschedule(void)
void em_atomic_processing_end(void)
em_sched_context_type_t
@ EM_SCHED_CONTEXT_TYPE_ORDERED
@ EM_SCHED_CONTEXT_TYPE_NONE
@ EM_SCHED_CONTEXT_TYPE_ATOMIC
em_sched_context_type_t sched_context_type
Definition em_mem.h:210
queue_elem_t * sched_q_elem
Definition em_mem.h:216
em_locm_current_t current
Definition em_mem.h:228
int event_burst_cnt
Definition em_mem.h:237
queue_elem_flags_t flags