OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 7:42 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: gcc asm '.section.text.lock"
PostPosted: Tue Oct 25, 2016 12:14 am 
Offline
Member
Member

Joined: Wed Dec 18, 2013 9:10 am
Posts: 84
I am reading the source code of linux 2.4.
The following code is the entry of 'up' operation of semaphore. It's located in include/asm-i386-semaphore.h .
Code:
static inline void down(struct semaphore * sem)
{
   __asm__ __volatile__(
      "# atomic down operation\n\t"
      LOCK "decl %0\n\t"     /* --sem->count */
      "js 2f\n"
      "1:\n"
      ".section .text.lock,\"ax\"\n"       /* I don't understand this line*/
      "2:\tcall __down_failed\n\t"
      "jmp 1b\n"
      ".previous"
      :"=m" (sem->count)
      :"c" (sem)
      :"memory");
}

This line :
".section .text.lock,\"ax\"\n"
What's he doing? The syntax seems horrible. I even don't know how to google it.

Could any friend help me? Thanks!


Top
 Profile  
 
 Post subject: Re: gcc asm '.section.text.lock"
PostPosted: Tue Oct 25, 2016 1:32 am 
Offline
Member
Member

Joined: Wed Dec 18, 2013 9:10 am
Posts: 84
I see. The code between
Code:
".section .text.lock, \"ax"\n"
...
".previous"

is sent to a special section by gcc.
Because these instructions are not often 'hit', we separate them to another place to get a shorter function body of down().

But i still don't understand what 's the meaning of 'ax'.


Top
 Profile  
 
 Post subject: Re: gcc asm '.section.text.lock"
PostPosted: Tue Oct 25, 2016 1:44 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5137
miaowei wrote:
But i still don't understand what 's the meaning of 'ax'.

It's explained in the manual.


Top
 Profile  
 
 Post subject: Re: gcc asm '.section.text.lock"
PostPosted: Tue Oct 25, 2016 7:23 am 
Offline
Member
Member

Joined: Wed Dec 18, 2013 9:10 am
Posts: 84
Octocontrabass wrote:
miaowei wrote:
But i still don't understand what 's the meaning of 'ax'.

It's explained in the manual.

Thank you very much, Octocontrabass.
I treated it as the 'AX' register ... :(


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 51 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group