Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
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
Esteban Blanc
proview
Commits
38dd5b05
Commit
38dd5b05
authored
Apr 28, 2004
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New synchronization mechanism for qcom
parent
427bccf7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
168 additions
and
2 deletions
+168
-2
src/lib/rt/src/os_linux/rt_futex.c
src/lib/rt/src/os_linux/rt_futex.c
+77
-0
src/lib/rt/src/os_linux/rt_futex.h
src/lib/rt/src/os_linux/rt_futex.h
+19
-0
src/lib/rt/src/os_linux/rt_qos.c
src/lib/rt/src/os_linux/rt_qos.c
+72
-2
No files found.
src/lib/rt/src/os_linux/rt_futex.c
0 → 100644
View file @
38dd5b05
/* rt_futex.c -- Futex operations
PROVIEW/R
Contains functions that are heavily os-dependant.
Author: Robert Karlsson 21 Apr 2004
Description:
This module provides an interface to futexes - "fast user level
locking in Linux". This is achieved through the multiplexing
system call sys_futex(). As implemented below this interface provides
a synchronization mechanism that can be used both between threads
in one process as well as between threads in different processes */
#if !defined(OS_LINUX)
# error "This file is valid only for OS_LINUX"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/syscall.h>
#include <unistd.h>
#define FUTEX_WAIT (0)
#define FUTEX_WAKE (1)
#define FUTEX_FD (2)
#define FUTEX_REQUEUE (3)
int
futex_wait
(
int
*
futex
,
int
val
)
{
int
ok
;
ok
=
syscall
(
SYS_futex
,
futex
,
FUTEX_WAIT
,
val
,
NULL
);
if
(
ok
==
-
1
)
{
return
errno
;
}
else
{
return
ok
;
}
}
int
futex_timed_wait
(
int
*
futex
,
int
val
,
const
struct
timespec
*
timespec
)
{
int
ok
;
ok
=
syscall
(
SYS_futex
,
futex
,
FUTEX_WAIT
,
val
,
timespec
);
if
(
ok
==
-
1
)
{
return
errno
;
}
else
{
return
ok
;
}
}
int
futex_wake
(
int
*
futex
,
int
nr
)
{
int
ok
;
ok
=
syscall
(
SYS_futex
,
futex
,
FUTEX_WAKE
,
nr
,
NULL
);
if
(
ok
==
-
1
)
{
return
errno
;
}
else
{
return
ok
;
}
}
src/lib/rt/src/os_linux/rt_futex.h
0 → 100644
View file @
38dd5b05
/* rt_futex.h */
#ifndef rt_futex_h
#define rt_futex_h
#ifdef __cplusplus
extern
"C"
{
#endif
int
futex_wait
(
int
*
futex
,
int
val
);
int
futex_timed_wait
(
int
*
futex
,
int
val
,
const
struct
timespec
*
timespec
);
int
futex_wake
(
int
*
futex
,
int
nr
);
#ifdef __cplusplus
}
#endif
#endif
src/lib/rt/src/os_linux/rt_qos.c
View file @
38dd5b05
...
...
@@ -26,10 +26,11 @@
#include "rt_qdb.h"
#include "rt_pool.h"
#include "rt_hash.h"
#include "rt_futex.h"
pwr_tBoolean
qos_WaitQue
(
qos_WaitQue
Old
(
pwr_tStatus
*
status
,
qdb_sQue
*
qp
,
int
tmo
...
...
@@ -88,8 +89,57 @@ qos_WaitQue (
return
signal
;
}
pwr_tBoolean
qos_WaitQue
(
pwr_tStatus
*
status
,
qdb_sQue
*
qp
,
int
tmo
)
{
pwr_tDeltaTime
dtime
;
int
ok
;
pwr_tBoolean
signal
=
FALSE
;
pwr_dStatus
(
sts
,
status
,
QCOM__SUCCESS
);
qdb_AssumeLocked
;
if
(
tmo
==
qcom_cTmoNone
)
return
FALSE
;
qp
->
lock
.
waiting
=
TRUE
;
qp
->
lock
.
pid
=
0
;
qdb_Unlock
;
if
(
tmo
!=
qcom_cTmoEternal
)
{
ok
=
futex_timed_wait
(
&
(
qp
->
lock
.
pid
),
0
,
(
struct
timespec
*
)
time_MsToD
(
&
dtime
,
tmo
));
}
else
{
for
(;;)
{
ok
=
futex_wait
(
&
(
qp
->
lock
.
pid
),
0
);
if
(
ok
==
EINTR
)
continue
;
break
;
}
}
if
(
ok
==
EWOULDBLOCK
)
{
errh_Error
(
"waitQue - Deadlock would occur"
);
}
qdb_Lock
;
if
((
qp
->
lock
.
waiting
)
||
(
ok
==
ETIMEDOUT
))
{
*
sts
=
QCOM__TMO
;
qp
->
lock
.
waiting
=
FALSE
;
}
else
{
signal
=
TRUE
;
}
return
signal
;
}
pwr_tStatus
qos_SignalQue
(
qos_SignalQue
Old
(
pwr_tStatus
*
status
,
qdb_sQue
*
qp
)
...
...
@@ -114,7 +164,27 @@ qos_SignalQue (
return
TRUE
;
}
pwr_tStatus
qos_SignalQue
(
pwr_tStatus
*
status
,
qdb_sQue
*
qp
)
{
int
ok
;
pwr_dStatus
(
sts
,
status
,
QCOM__SUCCESS
);
qdb_AssumeLocked
;
if
(
qp
->
lock
.
waiting
)
{
qp
->
lock
.
waiting
=
FALSE
;
ok
=
futex_wake
(
&
(
qp
->
lock
.
pid
),
INT_MAX
);
}
return
TRUE
;
}
qdb_sQlock
*
qos_CreateQlock
(
...
...
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