문제

I want to establish connection between kernel module and user application with the kernel as a client. In other words, kernel will send message to the user app, wait for reply, receive reply, and then continue execution.

For example, inside kernel I will send message and then wait for reply.

// inside kernel
nlmsg_unicast();

wait_until_user_reply();

/* process reply */
/* continue execution.. */

while inside user,

while (1) {
   // inside user
   recvmsg();

   /* assembly reply.. */

   sendmsg();
}

however, what netlink protocol does is invoking a callback function every time user sends message. What I want is to make kernel wait for a reply from user, then continue the execution. Is waiting in a busy loop on a global variable which is updated inside callback function feasible? I tried but I think that's not a very good solution.

Can I do something like "sleep until a reply come". Can I put the kernel to sleep?

도움이 되었습니까?

해결책

I have resolved this problem using wait_for_completion. It turns out that it wasn't that hard.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top