- In the dispatch function of the server, it extracts a cap from the stream L4::Ipc::Snd_fpage cap; ios >> cap; Why do we use "cap" here? What is the difference between "cap" and the receive item(rec_cap)?
cap is the flexpage describing the mapping. In particular, it can be used to check the success of the mapping. Otherwise the move call would fail.
- In this example, when does the map process finish? I think it looks like it has already finished when the server receives the request. If so, does it mean that the kernel preforms the map operation automatically? But how does the kernel know the capability needs to be mapped into server?
The mapping is done during the call. During IPC, the kernel matches receive and send items and performs the mapping. This is exactly why the server has to use setup_wait to insert the receive item.