Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
FORMUS3IC_LAS3
/
embb
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
2fdf534c
authored
Mar 24, 2017
by
Michael Schmid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edited time for more safety with overflow, and thread join method
parent
bffe02d6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
16 deletions
+11
-16
base_c/include/embb/base/c/internal/atomic/compare_and_swap.h
+1
-1
base_c/src/thread.c
+2
-9
base_c/src/time.c
+8
-6
No files found.
base_c/include/embb/base/c/internal/atomic/compare_and_swap.h
View file @
2fdf534c
...
...
@@ -132,7 +132,7 @@ EMBB_DEFINE_COMPARE_AND_SWAP(4, "")
EMBB_PLATFORM_INLINE int EMBB_CAT2(embb_internal__atomic_compare_and_swap_, \
EMBB_PARAMETER_SIZE_BYTE)(EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* expected, \
EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) desired) { \
register
/*__extension__ */
uint64_t e_reg = ((uint64_t)*expected << 32U) | desired; \
register uint64_t e_reg = ((uint64_t)*expected << 32U) | desired; \
__asm__ __volatile__ ("cmpswap" EMBB_ATOMIC_TC_SIZE_SUFFIX " [%1]0, %A0\n\t" \
: "+d"(e_reg) \
: "a"(pointer_to_value) \
...
...
base_c/src/thread.c
View file @
2fdf534c
...
...
@@ -387,15 +387,8 @@ int embb_thread_join(embb_thread_t* thread, int *result_code) {
return
EMBB_ERROR
;
}
TickType_t
xTicksToWait
=
0xFFFFFFFF
;
TimeOut_t
xTimeOut
;
vTaskSetTimeOutState
(
&
xTimeOut
);
while
(
thread
->
embb_internal_handle
!=
NULL
)
{
if
(
xTaskCheckForTimeOut
(
&
xTimeOut
,
&
xTicksToWait
)
!=
pdFALSE
)
{
break
;
}
while
(
thread
->
embb_internal_handle
!=
NULL
&&
eTaskGetState
(
thread
->
embb_internal_handle
)
!=
eDeleted
)
{
taskYIELD
();
}
if
(
thread
->
embb_internal_arg
!=
NULL
)
{
...
...
base_c/src/time.c
View file @
2fdf534c
...
...
@@ -105,20 +105,22 @@ int embb_time_in(embb_time_t* time, const embb_duration_t* duration) {
#ifdef EMBB_PLATFORM_THREADING_RTOSTASKS
#include <FreeRTOS/FreeRTOSConfig.h>
#include <FreeRTOS/task.h>
#include <stdint.h>
int
embb_time_in
(
embb_time_t
*
time
,
const
embb_duration_t
*
duration
)
{
if
(
time
==
NULL
||
duration
==
NULL
)
{
return
EMBB_ERROR
;
}
//scm34681: implement correctly for different ticks/second
//scm34681: check for overflow of tick count
uint32_t
ticks_count
=
xTaskGetTickCount
();
time
->
seconds
=
ticks_count
/
1000
;
time
->
nanoseconds
=
(
ticks_count
%
1000
)
*
1000000
;
uint64_t
ticks_count
=
xTaskGetTickCount
();
time
->
seconds
=
ticks_count
/
configTICK_RATE_HZ
;
time
->
nanoseconds
=
((
ticks_count
%
configTICK_RATE_HZ
)
*
1000000000ul
)
/
configTICK_RATE_HZ
;
if
(
time
->
seconds
+
duration
->
seconds
>
EMBB_TIME_MAX_SECONDS
)
{
ticks_count
=
(
uint64_t
)(
duration
->
seconds
*
configTICK_RATE_HZ
+
(
duration
->
nanoseconds
*
configTICK_RATE_HZ
/
1000000000ul
));
if
(
ticks_count
>
UINT32_MAX
||
time
->
seconds
+
duration
->
seconds
>
EMBB_TIME_MAX_SECONDS
)
{
return
EMBB_OVERFLOW
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment