ugBASIC
1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
forbid.c
Go to the documentation of this file.
1
/*****************************************************************************
2
* ugBASIC - an isomorphic BASIC language compiler for retrocomputers *
3
*****************************************************************************
4
* Copyright 2021-2026 Marco Spedaletti (asimov@mclink.it)
5
*
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
* you may not use this file except in compliance with the License.
8
* You may obtain a copy of the License at
9
*
10
* http://www.apache.org/licenses/LICENSE-2.0
11
*
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
17
*----------------------------------------------------------------------------
18
* Concesso in licenza secondo i termini della Licenza Apache, versione 2.0
19
* (la "Licenza"); è proibito usare questo file se non in conformità alla
20
* Licenza. Una copia della Licenza è disponibile all'indirizzo:
21
*
22
* http://www.apache.org/licenses/LICENSE-2.0
23
*
24
* Se non richiesto dalla legislazione vigente o concordato per iscritto,
25
* il software distribuito nei termini della Licenza è distribuito
26
* "COSÌ COM'È", SENZA GARANZIE O CONDIZIONI DI ALCUN TIPO, esplicite o
27
* implicite. Consultare la Licenza per il testo specifico che regola le
28
* autorizzazioni e le limitazioni previste dalla medesima.
29
****************************************************************************/
30
31
/****************************************************************************
32
* INCLUDE SECTION
33
****************************************************************************/
34
35
#include "
../../ugbc.h
"
36
37
/****************************************************************************
38
* CODE SECTION
39
****************************************************************************/
40
46
/* <usermanual>
47
@keyword FORBID
48
49
@english
50
51
In some situations, it is necessary to ensure that a sequence of operations is executed
52
atomically, without interruption. The ''FORBID'' instruction plays a crucial role
53
in this way, offering the programmer a way to take full control of the system's execution,
54
at least temporarily.
55
56
In simple terms, ''FORBID'' blocks any attempt by ugBASIC to pass execution from one task
57
to another. This means that the task that called ''FORBID'' will continue to execute
58
its code without interruption until a corresponding call to ''ALLOW'' is made. The ''FORBID''
59
ensures that a sequence of critical operations is executed indivisibly,
60
without interference from other tasks. This gives the programmer granular control
61
over the system's execution.
62
63
@italian
64
65
In alcune situazioni, è necessario garantire che una sequenza di operazioni venga
66
eseguita in modo atomico, senza interruzioni. L'istruzione ''FORBID'' svolge un ruolo
67
cruciale in questo senso, offrendo al programmatore un modo per assumere il pieno
68
controllo dell'esecuzione del sistema, almeno temporaneamente.
69
70
In parole povere, ''FORBID'' blocca qualsiasi tentativo di ugBASIC di passare
71
l'esecuzione da un task a un altro. Ciò significa che il task che ha chiamato
72
''FORBID'' continuerà a eseguire il suo codice senza interruzioni finché non verrà
73
effettuata una chiamata corrispondente a ''ALLOW''. ''FORBID'' assicura che
74
una sequenza di operazioni critiche venga eseguita in modo indivisibile,
75
senza interferenze da parte di altri task. Ciò fornisce al programmatore
76
un controllo granulare sull'esecuzione del sistema.
77
78
@syntax FORBID
79
80
@example PARALLEL PROCEDURE test
81
@example FORBID
82
@example ' busy waiting, multitasking is suspended!
83
@example FOR i=0 TO 1000: WAIT 1 MS : NEXT i
84
@example ALLOW
85
@example END PROC
86
87
@target all
88
</usermanual> */
89
void
forbid
(
Environment
* _environment ) {
90
91
_environment->
anyProtothread
= 1;
92
93
if
( ! _environment->
protothreadForbid
) {
94
_environment->
protothreadForbid
= 1;
95
}
else
{
96
CRITICAL_MULTITASKING_ALREADY_FORBIDDEN
();
97
}
98
99
}
100
forbid
void forbid(Environment *_environment)
Emit code for YIELD.
Definition
forbid.c:89
_Environment::anyProtothread
int anyProtothread
Definition
ugbc.h:2835
_Environment::protothreadForbid
int protothreadForbid
Definition
ugbc.h:2845
ugbc.h
Environment
struct _Environment Environment
Structure of compilation environment.
CRITICAL_MULTITASKING_ALREADY_FORBIDDEN
#define CRITICAL_MULTITASKING_ALREADY_FORBIDDEN()
Definition
ugbc.h:3701
Z:
ugbasic
ugbc
src
targets
common
forbid.c
Generated by
1.16.1