Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lizhongxiao
OpenXG-RAN
Commits
c5786096
Commit
c5786096
authored
Jan 30, 2024
by
mir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
POLL_AND_SLEEP added
parent
51c1c30c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
common/utils/task_manager/thread_pool/task_manager.c
common/utils/task_manager/thread_pool/task_manager.c
+58
-0
No files found.
common/utils/task_manager/thread_pool/task_manager.c
View file @
c5786096
...
...
@@ -22,6 +22,10 @@
#include <ctype.h> // toupper
//#define POLL_AND_SLEEP
#if defined (__i386__) || defined(__x86_64__)
#define pause_or_yield __builtin_ia32_pause
...
...
@@ -339,6 +343,58 @@ ret_try_t try_pop_not_q(not_q_t* q)
return
ret
;
}
#ifdef POLL_AND_SLEEP
static
bool
pop_not_q
(
not_q_t
*
q
,
ret_try_t
*
out
)
{
assert
(
q
!=
NULL
);
assert
(
out
!=
NULL
);
assert
(
q
->
done
==
0
||
q
->
done
==
1
);
int
rc
=
pthread_mutex_lock
(
&
q
->
mtx
);
assert
(
rc
==
0
);
assert
(
q
->
done
==
0
||
q
->
done
==
1
);
const
struct
timespec
ns
=
{
0
,
1024
};
int
cnt
=
0
;
while
(
size_seq_ring_task
(
&
q
->
r
)
==
0
&&
q
->
done
==
0
){
rc
=
pthread_mutex_unlock
(
&
q
->
mtx
);
assert
(
rc
==
0
);
nanosleep
(
&
ns
,
NULL
);
int
rc
=
pthread_mutex_lock
(
&
q
->
mtx
);
assert
(
rc
==
0
);
if
(
cnt
==
1024
){
cnt
=
0
;
pthread_cond_wait
(
&
q
->
cv
,
&
q
->
mtx
);
}
cnt
++
;
}
//printf("Waking idx %ld %ld \n", q->idx, time_now_us());
assert
(
q
->
done
==
0
||
q
->
done
==
1
);
if
(
q
->
done
==
1
){
int
rc
=
pthread_mutex_unlock
(
&
q
->
mtx
);
assert
(
rc
==
0
);
return
false
;
}
out
->
t
=
pop_seq_ring_task
(
&
q
->
r
);
rc
=
pthread_mutex_unlock
(
&
q
->
mtx
);
assert
(
rc
==
0
);
return
true
;
}
#else
static
bool
pop_not_q
(
not_q_t
*
q
,
ret_try_t
*
out
)
{
...
...
@@ -370,6 +426,8 @@ bool pop_not_q(not_q_t* q, ret_try_t* out)
return
true
;
}
#endif
static
void
done_not_q
(
not_q_t
*
q
)
...
...
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