Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Miosix Kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Avionics
Software Development
Miosix Kernel
Commits
9d8403eb
Commit
9d8403eb
authored
2 years ago
by
Federico
Browse files
Options
Downloads
Patches
Plain Diff
Reorder Queue methods
parent
b7dcc404
Branches
Branches containing commit
No related tags found
2 merge requests
!40
Update to Miosix 2.7
,
!17
Draft: Improved miosix build system and fixed cmake scripts
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
miosix/kernel/queue.h
+57
-57
57 additions, 57 deletions
miosix/kernel/queue.h
with
57 additions
and
57 deletions
miosix/kernel/queue.h
+
57
−
57
View file @
9d8403eb
...
...
@@ -88,13 +88,6 @@ public:
*/
void
waitUntilNotFull
();
/**
* Get an element from the queue. If the queue is empty, then sleep until
* an element becomes available.
* \param elem an element from the queue
*/
void
get
(
T
&
elem
);
/**
* Put an element to the queue. If the queue is full, then sleep until a
* place becomes available.
...
...
@@ -103,46 +96,53 @@ public:
void
put
(
const
T
&
elem
);
/**
*
Ge
t an element
from
the queue, only if th
e
queue is not
empty
.<br>
*
Pu
t an element
to
the queue, only if th queue is not
full
.<br>
* Can ONLY be used inside an IRQ, or when interrupts are disabled.
* \param elem
an
element
from the queue
. The element
is vali
d only if the
* \param elem element
to add
. The element
has been adde
d only if the
* return value is true
* \return true if the queue was not
empty
* \return true if the queue was not
full.
*/
bool
IRQ
get
(
T
&
elem
);
bool
IRQ
put
(
const
T
&
elem
);
/**
*
Ge
t an element
from
the queue, only if th
e
queue is not
empty
.<br>
*
Pu
t an element
to
the queue, only if th queue is not
full
.<br>
* Can ONLY be used inside an IRQ, or when interrupts are disabled.
* \param elem
an
element
from the queue
. The element
is vali
d only if the
* \param elem element
to add
. The element
has been adde
d only if the
* return value is true
* \param hppw is not modified if no thread is woken or if the woken thread
* has a lower or equal priority than the currently running thread, else is
* set to true
* \return true if the queue was not
empty
* \return true if the queue was not
full.
*/
bool
IRQ
get
(
T
&
elem
,
bool
&
hppw
);
bool
IRQ
put
(
const
T
&
elem
,
bool
&
hppw
);
/**
* Put an element to the queue, only if th queue is not full.<br>
* Get an element from the queue. If the queue is empty, then sleep until
* an element becomes available.
* \param elem an element from the queue
*/
void
get
(
T
&
elem
);
/**
* Get an element from the queue, only if the queue is not empty.<br>
* Can ONLY be used inside an IRQ, or when interrupts are disabled.
* \param elem element
to add
. The element
has been adde
d only if the
* \param elem
an
element
from the queue
. The element
is vali
d only if the
* return value is true
* \return true if the queue was not
full.
* \return true if the queue was not
empty
*/
bool
IRQ
put
(
const
T
&
elem
);
bool
IRQ
get
(
T
&
elem
);
/**
*
Pu
t an element
to
the queue, only if th queue is not
full
.<br>
*
Ge
t an element
from
the queue, only if th
e
queue is not
empty
.<br>
* Can ONLY be used inside an IRQ, or when interrupts are disabled.
* \param elem element
to add
. The element
has been adde
d only if the
* \param elem
an
element
from the queue
. The element
is vali
d only if the
* return value is true
* \param hppw is not modified if no thread is woken or if the woken thread
* has a lower or equal priority than the currently running thread, else is
* set to true
* \return true if the queue was not
full.
* \return true if the queue was not
empty
*/
bool
IRQ
put
(
const
T
&
elem
,
bool
&
hppw
);
bool
IRQ
get
(
T
&
elem
,
bool
&
hppw
);
/**
* Clear all items in the queue.<br>
...
...
@@ -215,35 +215,59 @@ void Queue<T,len>::waitUntilNotFull()
}
template
<
typename
T
,
unsigned
int
len
>
void
Queue
<
T
,
len
>::
get
(
T
&
elem
)
void
Queue
<
T
,
len
>::
put
(
const
T
&
elem
)
{
FastInterruptDisableLock
dLock
;
IRQwakeWaitingThread
();
while
(
is
Empty
())
while
(
is
Full
())
{
waiting
=
Thread
::
IRQgetCurrentThread
();
Thread
::
IRQenableIrqAndWait
(
dLock
);
IRQwakeWaitingThread
();
}
numElem
--
;
elem
=
buffer
[
ge
tPos
];
if
(
++
ge
tPos
==
len
)
ge
tPos
=
0
;
numElem
++
;
buffer
[
pu
tPos
]
=
elem
;
if
(
++
pu
tPos
==
len
)
pu
tPos
=
0
;
}
template
<
typename
T
,
unsigned
int
len
>
void
Queue
<
T
,
len
>::
put
(
const
T
&
elem
)
bool
Queue
<
T
,
len
>::
IRQput
(
const
T
&
elem
)
{
IRQwakeWaitingThread
();
if
(
isFull
())
return
false
;
numElem
++
;
buffer
[
putPos
]
=
elem
;
if
(
++
putPos
==
len
)
putPos
=
0
;
return
true
;
}
template
<
typename
T
,
unsigned
int
len
>
bool
Queue
<
T
,
len
>::
IRQput
(
const
T
&
elem
,
bool
&
hppw
)
{
if
(
waiting
&&
(
Thread
::
IRQgetCurrentThread
()
->
IRQgetPriority
()
<
waiting
->
IRQgetPriority
()))
hppw
=
true
;
IRQwakeWaitingThread
();
if
(
isFull
())
return
false
;
numElem
++
;
buffer
[
putPos
]
=
elem
;
if
(
++
putPos
==
len
)
putPos
=
0
;
return
true
;
}
template
<
typename
T
,
unsigned
int
len
>
void
Queue
<
T
,
len
>::
get
(
T
&
elem
)
{
FastInterruptDisableLock
dLock
;
IRQwakeWaitingThread
();
while
(
is
Full
())
while
(
is
Empty
())
{
waiting
=
Thread
::
IRQgetCurrentThread
();
Thread
::
IRQenableIrqAndWait
(
dLock
);
IRQwakeWaitingThread
();
}
numElem
++
;
buffer
[
pu
tPos
]
=
elem
;
if
(
++
pu
tPos
==
len
)
pu
tPos
=
0
;
numElem
--
;
elem
=
buffer
[
ge
tPos
];
if
(
++
ge
tPos
==
len
)
ge
tPos
=
0
;
}
template
<
typename
T
,
unsigned
int
len
>
...
...
@@ -270,30 +294,6 @@ bool Queue<T,len>::IRQget(T& elem, bool& hppw)
return
true
;
}
template
<
typename
T
,
unsigned
int
len
>
bool
Queue
<
T
,
len
>::
IRQput
(
const
T
&
elem
)
{
IRQwakeWaitingThread
();
if
(
isFull
())
return
false
;
numElem
++
;
buffer
[
putPos
]
=
elem
;
if
(
++
putPos
==
len
)
putPos
=
0
;
return
true
;
}
template
<
typename
T
,
unsigned
int
len
>
bool
Queue
<
T
,
len
>::
IRQput
(
const
T
&
elem
,
bool
&
hppw
)
{
if
(
waiting
&&
(
Thread
::
IRQgetCurrentThread
()
->
IRQgetPriority
()
<
waiting
->
IRQgetPriority
()))
hppw
=
true
;
IRQwakeWaitingThread
();
if
(
isFull
())
return
false
;
numElem
++
;
buffer
[
putPos
]
=
elem
;
if
(
++
putPos
==
len
)
putPos
=
0
;
return
true
;
}
//This partial specialization is meant to to produce compiler errors in case an
//attempt is made to instantiate a Queue with zero size, as it is forbidden
template
<
typename
T
>
class
Queue
<
T
,
0
>
{};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment