title: Thread Context Switching
body: <p>I am working on a C/C++ project which involves a UI and a background service which does some heavy processing by fetching data over the network. In order that my UI doesn't become unresponsive, I would want to spawn a separate thread and then call the background service within that thread, while another thread will display a busy indication in the UI. Once the background service completes it's job, I would want to switch the thread context from background thread to the UI thread, So that the busy indication gets removed and further screen flows can be shown.
  I believe this is the usual way most of the UI works. What i would want to know is what are the efficient and best ways of achieving this. Right now i do not have a code implemented for the above and I am just asking for ideas and best ways of doing this.</p>
  
  <p>The platform is Linux.
  The UI framework I am using is a custom UI framework which provides a SDK for UI development but unlike most UI frameworks would it provides nothing for the scenario I mentioned. It is almost deprecated framework but needs to be used for this project which is a pain so only option is I can use Pthread or System v with some wrappers over actual calls which would help me keep the implementation portable on different platforms.  </p>
  
  <p>I cannot use Boost Threads because of certain limitations of the embedded environment.<br>
  Any suggestions and explanation about how the context switch takes place will be really helpful.</p>