Peng Zhang
Peng Zhang

Reputation: 3585

How can I tell a function enters kernel or not

I am implementing a program to run in user space as often as possible. So I am trying to call functions which enter and leave kernel space as less as possible. For example, I use some DMA API which read/write but bypass the kernel.

I don't know how to tell a function needs to enter kernel space or not. For example, I want to call getenv() to get environment variables set by the host, but worrying it may pass my program and enter the kernel space. I cannot find this imformation from man pages. Here is the man page of getenv().

Upvotes: 1

Views: 169

Answers (2)

Don Shankin
Don Shankin

Reputation: 440

Have you run your program through strace? That will let you know where you are making system calls that will enter kernel space

Upvotes: 4

Luis404
Luis404

Reputation: 196

I thinks most IO functions will cause your program to the kernel? Maybe you should check the system APIs that used by you

Upvotes: 0

Related Questions