PIDUINO
Loading...
Searching...
No Matches
scheduler.h
1/* Copyright © 2018-2025 Pascal JEAN, All rights reserved.
2 * This file is part of the Piduino Library.
3 *
4 * The Piduino Library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 3 of the License, or (at your option) any later version.
8 *
9 * The Piduino Library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with the Piduino Library; if not, see <http://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include <mutex>
20
30namespace Piduino {
31
38 class Scheduler {
39
40 public:
45 Scheduler (int interruptPriority = -1) : _interruptPriority (interruptPriority) {
46 if (interruptPriority < 0) {
48 }
50 }
51
61 inline void noInterrupts() {
62
63 _intMutex.lock();
66 }
67
75 inline void interrupts() {
76
78 _intMutex.unlock();
79 }
80
84 int interrupPriority () const {
85 return _interruptPriority;
86 }
87
94 void setInterrupPriority (int value) {
95 std::unique_lock<std::mutex> lock (_intMutex);
96 _interruptPriority = value;
97 }
98
109 static void setRtPriority (int priority);
110
114 static int rtPriority();
115
119 static int rtPriorityMin();
120
124 static int rtPriorityMax();
125
132 static void yield();
133
134 protected:
137 std::mutex _intMutex;
138 };
139}
140
145/* ========================================================================== */
void interrupts()
Passage en mode "avec interruptions".
Definition scheduler.h:75
static void setRtPriority(int priority)
Définis la priorité en temps réel du thread appelant.
void setInterrupPriority(int value)
Modifie la priorité affectée lors d'un appel à noInterrupts()
Definition scheduler.h:94
static void yield()
force le thread appelant à libérer le CPU.
int interrupPriority() const
Priorité affectée lors d'un appel à noInterrupts()
Definition scheduler.h:84
static int rtPriorityMin()
Priorité minimale du thread appelant.
static int rtPriority()
Priorité du thread appelant.
Scheduler(int interruptPriority=-1)
Constructeur.
Definition scheduler.h:45
std::mutex _intMutex
Definition scheduler.h:137
static int rtPriorityMax()
Priorité maximale du thread appelant.
void noInterrupts()
Passage en mode "sans interruptions".
Definition scheduler.h:61
Global namespace for Piduino.
Definition board.h:28