Skip to content

pcn message handling

bxatnarf edited this page Jan 17, 2020 · 1 revision

A message type is defined by a set of macros.

REGISTER_KMSG_HANDLER(PCN_KMSG_TYPE_TASK_MIGRATE, clone_request);  

https://github.com/ssrg-vt/popcorn-kernel/blob/e44428e9aa4f9656322749dc94834f59659eeb3b/kernel/popcorn/process_server.c#L1048

expanding the macro (in kernel/popcorn/types.h)

#define REGISTER_KMSG_HANDLER(x, y) \
	pcn_kmsg_register_callback(x, handle_##y) (

the ## in the #define macro does string concatenation, so it really is calling

pcn_kmsg_register_callback(PCN_KMSG_TYPE_TASK_MIGRATE, handle_clone_request);

pcn_kmsg_register_callback defined here -- https://github.com/ssrg-vt/popcorn-kernel/blob/48ff7e48d20b74dde12b497d7fb962513a64107f/kernel/popcorn/pcn_kmsg.c#L30 it just maintains an array static pcn_kmsg_cbftn pcn_kmsg_cbftns[PCN_KMSG_TYPE_MAX] -- which corresponds message types to callback handler

Then when a message is processed by pcn_kmsg_process, it looks up the callback corresponding to the message type https://github.com/ssrg-vt/popcorn-kernel/blob/48ff7e48d20b74dde12b497d7fb962513a64107f/kernel/popcorn/pcn_kmsg.c#L49

pcn_kmsg_process is called directly by the message layer / socket recv handler https://github.com/ssrg-vt/popcorn-kernel/blob/48ff7e48d20b74dde12b497d7fb962513a64107f/msg_layer/socket.c#L117