Switch from User space to Kernel space.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 

Can any one tell me what’s going on in following code (esp code in RED color) ?

 

#define _syscall1(type,name,type1,arg1) \
type name(type1 arg1) \
{ \
        long __res; \
        __asm__ volatile ("int $0x80" \
        : "=a" (__res) \
        : "" (__NR_##name),"b" ((long)(arg1))); \
        __syscall_return(type,__res); \
}

 

This has been taken from ‘unistd.h’ file in kernel sources. It’s a code which actually creates a stub, so that user process can make a call to system call.

 

My question is for having an access this code (macro) user process or library function used by user program must include this file (‘unistd.h’). Is it like this that this file is included by a library or user program which makes a call to system call. Actually it is the first time that I am studying about how the control switches from user space to kernel space. I want to know exact code which make this switch. I think that its this stub only which allow the control to switch from user space to kernel space.

 

One more thing, Please let me know what does the code in RED color is doing. Its an assembly code, please explain it.

 

Regards,

Gaurav

 


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux