Thanks Avadh. Let me try to digest your answer: In setup_qemu_switch_all_ctx(), we basically call setup_qemu_switch() for every context and that inside setup_qemu_switch(), we call setup_cpu_env() which sets qemu's env and cpu_single_env to env. Are these the global variables in qemu that you are referring to? By calling this on every context, only the last context's state is copied to env and cpu_single_env, right?
Thanks, - Bhushan On Sat, Sep 22, 2012 at 3:58 PM, avadh patel <[email protected]> wrote: > > > On Sat, Sep 22, 2012 at 1:41 PM, Vidyabhushan Mohan <[email protected] > > wrote: > >> Ok, I figured out that Context is not for every OS process but represents >> a hardware context in a smp. >> Also realized that ptl_create_new_context is called to create a new >> context during cpu initialization phase. >> Now, can someone explain the difference between setup_qemu_switch and >> setup_qemu_switch_all_ctx? More importantly, when should I call the former >> and the latter? >> >> Its because of QEMU uses global variable to point to currently running > cpu context, as emulation mode it runs only one cpu at a time. In > simulation mode we run all cpus in each cycle. Now when we switch to QEMU > to emulate IO or some complex opcode then we have to set correct cpu's > context as global variable so we have this function > 'setup_qemu_switch_all_ctx' which will set global context variable to > 'context' passed to that function. Hope this makes any sense :) > > - Avadh > > Thanks, >> - Bhushan >> >> >> >> On Thu, Sep 20, 2012 at 5:15 PM, Vidyabhushan Mohan < >> [email protected]> wrote: >> >>> Hi, >>> I have a few questions regarding how a context is created and how >>> context switching happens in PTLSim. >>> *) When and where is a Context object created? struct Context is defined >>> in ptlhwdef.h >>> *) My understanding is that since Context is derived from CPUX86State, >>> each "OS" process would have it own context object. If so, when a context >>> switch happens in the OS, how does PTLSim switch from one Context object to >>> another. >>> *) I'm trying to pass a value stored in a register in one context, lets >>> say ctx.cr[3] (the page table base address stored in the cr3 register) >>> to a register in another context. >>> i.e. new_ctx.my_register = old_ctx.cr[3]. Could anyone point me to the >>> right way of doing this? >>> >>> Thanks a lot, >>> - Bhushan >>> >>> >> >> _______________________________________________ >> http://www.marss86.org >> Marss86-Devel mailing list >> [email protected] >> https://www.cs.binghamton.edu/mailman/listinfo/marss86-devel >> >> >
_______________________________________________ http://www.marss86.org Marss86-Devel mailing list [email protected] https://www.cs.binghamton.edu/mailman/listinfo/marss86-devel
