Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
25addffe
Commit
25addffe
authored
Aug 01, 2002
by
Paul Mackerras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PPC32: add __down_read_trylock and __down_write_trylock implementations.
parent
c6c91a46
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
1 deletion
+25
-1
include/asm-ppc/rwsem.h
include/asm-ppc/rwsem.h
+25
-1
No files found.
include/asm-ppc/rwsem.h
View file @
25addffe
...
...
@@ -72,12 +72,26 @@ static inline void init_rwsem(struct rw_semaphore *sem)
*/
static
inline
void
__down_read
(
struct
rw_semaphore
*
sem
)
{
if
(
atomic_inc_return
((
atomic_t
*
)(
&
sem
->
count
))
>
=
0
)
if
(
atomic_inc_return
((
atomic_t
*
)(
&
sem
->
count
))
>
0
)
smp_wmb
();
else
rwsem_down_read_failed
(
sem
);
}
static
inline
int
__down_read_trylock
(
struct
rw_semaphore
*
sem
)
{
int
tmp
;
while
((
tmp
=
sem
->
count
)
>=
0
)
{
if
(
tmp
==
cmpxchg
(
&
sem
->
count
,
tmp
,
tmp
+
RWSEM_ACTIVE_READ_BIAS
))
{
smp_wmb
();
return
1
;
}
}
return
0
;
}
/*
* lock for writing
*/
...
...
@@ -93,6 +107,16 @@ static inline void __down_write(struct rw_semaphore *sem)
rwsem_down_write_failed
(
sem
);
}
static
inline
int
__down_write_trylock
(
struct
rw_semaphore
*
sem
)
{
int
tmp
;
tmp
=
cmpxchg
(
&
sem
->
count
,
RWSEM_UNLOCKED_VALUE
,
RWSEM_ACTIVE_WRITE_BIAS
);
smp_wmb
();
return
tmp
==
RWSEM_UNLOCKED_VALUE
;
}
/*
* unlock after reading
*/
...
...
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