Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 35839
b: refs/heads/master
c: 7ca2b49
h: refs/heads/master
i:
  35837: ff5a327
  35835: 131d826
  35831: 8c22e76
  35823: aeceb92
  35807: 6c014f5
  35775: 0ade7a3
  35711: 1fe702b
  35583: f5b7725
  35327: b57adbb
  34815: ef8e8ab
v: v3
  • Loading branch information
Andi Kleen authored and Andi Kleen committed Sep 26, 2006
1 parent 218d5b5 commit cc4705e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 33 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: add659bf8aa92f8b3f01a8c0220557c959507fb1
refs/heads/master: 7ca2b49b06a6d26e89e3535653889f1d7892b085
49 changes: 17 additions & 32 deletions trunk/include/asm-i386/semaphore.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,10 @@ static inline void down(struct semaphore * sem)
__asm__ __volatile__(
"# atomic down operation\n\t"
LOCK_PREFIX "decl %0\n\t" /* --sem->count */
"js 2f\n"
"1:\n"
LOCK_SECTION_START("")
"2:\tlea %0,%%eax\n\t"
"call __down_failed\n\t"
"jmp 1b\n"
LOCK_SECTION_END
"jns 2f\n"
"\tlea %0,%%eax\n\t"
"call __down_failed\n"
"2:"
:"+m" (sem->count)
:
:"memory","ax");
Expand All @@ -123,15 +120,12 @@ static inline int down_interruptible(struct semaphore * sem)
might_sleep();
__asm__ __volatile__(
"# atomic interruptible down operation\n\t"
"xorl %0,%0\n\t"
LOCK_PREFIX "decl %1\n\t" /* --sem->count */
"js 2f\n\t"
"xorl %0,%0\n"
"1:\n"
LOCK_SECTION_START("")
"2:\tlea %1,%%eax\n\t"
"call __down_failed_interruptible\n\t"
"jmp 1b\n"
LOCK_SECTION_END
"jns 2f\n\t"
"lea %1,%%eax\n\t"
"call __down_failed_interruptible\n"
"2:"
:"=a" (result), "+m" (sem->count)
:
:"memory");
Expand All @@ -148,15 +142,12 @@ static inline int down_trylock(struct semaphore * sem)

__asm__ __volatile__(
"# atomic interruptible down operation\n\t"
"xorl %0,%0\n\t"
LOCK_PREFIX "decl %1\n\t" /* --sem->count */
"js 2f\n\t"
"xorl %0,%0\n"
"1:\n"
LOCK_SECTION_START("")
"2:\tlea %1,%%eax\n\t"
"jns 2f\n\t"
"lea %1,%%eax\n\t"
"call __down_failed_trylock\n\t"
"jmp 1b\n"
LOCK_SECTION_END
"2:\n"
:"=a" (result), "+m" (sem->count)
:
:"memory");
Expand All @@ -166,22 +157,16 @@ static inline int down_trylock(struct semaphore * sem)
/*
* Note! This is subtle. We jump to wake people up only if
* the semaphore was negative (== somebody was waiting on it).
* The default case (no contention) will result in NO
* jumps for both down() and up().
*/
static inline void up(struct semaphore * sem)
{
__asm__ __volatile__(
"# atomic up operation\n\t"
LOCK_PREFIX "incl %0\n\t" /* ++sem->count */
"jle 2f\n"
"1:\n"
LOCK_SECTION_START("")
"2:\tlea %0,%%eax\n\t"
"call __up_wakeup\n\t"
"jmp 1b\n"
LOCK_SECTION_END
".subsection 0\n"
"jg 1f\n\t"
"lea %0,%%eax\n\t"
"call __up_wakeup\n"
"1:"
:"+m" (sem->count)
:
:"memory","ax");
Expand Down

0 comments on commit cc4705e

Please sign in to comment.