Hi Chen,
I think we currently can only migrate those new created threads. However, to migrate the first thread of an application (I think it is called thread0 in Genode) I need to get its capability. Do you know how I can get thread0's capability with in the main function of my app?
I don't think that this approach is the right way to follow. Instead, the policy should be imposed from outside the server by the server's parent process similar to how CPU priorities are handled. When the parent creates the CPU session for the child, it should pass the CPU policy as session argument to core. This makes it easy to start multiple instances of the same program with a different policy each.
Attached to this email, you find a patch that you may use as starting point. Please note that this is just a hacky quick shot. It enables you to specify the CPU number at the start node of a process in init's config. In the patch, I have modified the 'start' node of the 'demo.run' script where you can see how to use new the "cpu" argument. The CPU number is passed to core and ends up in the Fiasco.OC-specific constructor of 'Platform_thread'. I've put some 'PDBG' messages at the interesting points.
Please note that the CPU argument is not passed to the kernel yet - the patch solely shows how to pass the CPU number as CPU session argument for immediate children of init into core. As it stands, the CPU policy is not applied to further CPU sessions created by the respective child's subsystem. Also, the patch is known to break all base platforms except for 'base-foc'. Anyway, I hope it can serve you as starting point for further experimentation.
Cheers Norman