Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 771461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:39:27+00:00 2026-05-14T18:39:27+00:00

I am working on x86_64 machine. My linux kernel is also 64 bit kernel.

  • 0

I am working on x86_64 machine. My linux kernel is also 64 bit kernel. As there are different ways to implement a system call (int 80, syscall, sysenter), i wanted to know what type of system call my machine is using. I am newbie to linux. I have written a demo program.

#include <stdio.h>
int main()
{
  getpid();
  return 0;
}

getpid() does one system call. Can anybody give me a method to find which type of system call will be used by my machine for this program.. Thank you….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T18:39:27+00:00Added an answer on May 14, 2026 at 6:39 pm
    victory:~ # gcc getpid.c -o getpid -g
    victory:~ # gdb getpid
    <snip>
    (gdb) break main
    Breakpoint 1 at 0x400540: file getpid.c, line 4.
    (gdb) run
    Starting program: /root/getpid 
    
    Breakpoint 1, main () at getpid.c:4
    4     getpid();
    (gdb) disassemble
    Dump of assembler code for function main:
    0x000000000040053c <main+0>:    push   %rbp
    0x000000000040053d <main+1>:    mov    %rsp,%rbp
    0x0000000000400540 <main+4>:    mov    $0x0,%eax
    0x0000000000400545 <main+9>:    callq  0x400440 <getpid@plt>
    0x000000000040054a <main+14>:   mov    $0x0,%eax
    0x000000000040054f <main+19>:   leaveq 
    0x0000000000400550 <main+20>:   retq   
    End of assembler dump.
    

    Looks like our call to getpid() is actually a library call. Let’s set a breakpoint there and continue.

    (gdb) break getpid
    Breakpoint 2 at 0x7ffff7b29c00
    (gdb) cont
    Continuing.
    
    Breakpoint 2, 0x00007ffff7b29c00 in getpid () from /lib64/libc.so.6
    (gdb) disassemble
    Dump of assembler code for function getpid:
    0x00007ffff7b29c00 <getpid+0>:  mov    %fs:0x94,%edx
    0x00007ffff7b29c08 <getpid+8>:  cmp    $0x0,%edx
    0x00007ffff7b29c0b <getpid+11>: mov    %edx,%eax
    0x00007ffff7b29c0d <getpid+13>: jle    0x7ffff7b29c11 <getpid+17>
    0x00007ffff7b29c0f <getpid+15>: repz retq 
    0x00007ffff7b29c11 <getpid+17>: jne    0x7ffff7b29c1f <getpid+31>
    0x00007ffff7b29c13 <getpid+19>: mov    %fs:0x90,%eax
    0x00007ffff7b29c1b <getpid+27>: test   %eax,%eax
    0x00007ffff7b29c1d <getpid+29>: jne    0x7ffff7b29c0f <getpid+15>
    0x00007ffff7b29c1f <getpid+31>: mov    $0x27,%eax
    0x00007ffff7b29c24 <getpid+36>: syscall 
    0x00007ffff7b29c26 <getpid+38>: test   %edx,%edx
    0x00007ffff7b29c28 <getpid+40>: mov    %rax,%rsi
    0x00007ffff7b29c2b <getpid+43>: jne    0x7ffff7b29c0f <getpid+15>
    0x00007ffff7b29c2d <getpid+45>: mov    %esi,%fs:0x90
    0x00007ffff7b29c35 <getpid+53>: mov    %esi,%eax
    0x00007ffff7b29c37 <getpid+55>: retq   
    End of assembler dump.
    

    Buried in the getpid() library is the syscall assembler instruction. This is an AMD64 instruction that supports a fast context switch to ring0 for the purpose of system calls.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 381k
  • Answers 381k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes, WSDL/SOAP (or WS-* in general) is an overkill because… May 14, 2026 at 10:12 pm
  • Editorial Team
    Editorial Team added an answer Here's a cut and paste (and rename, to protect the… May 14, 2026 at 10:12 pm
  • Editorial Team
    Editorial Team added an answer I would use code from http://www.mredkj.com/javascript/numberFormat.html to add commas: function… May 14, 2026 at 10:12 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.