2009年1月22日木曜日

cpu_index

exec.c の cpu_exec_init() を見ればわかるけど、全ての cpu_init()  (実体は cpu_arm_init() などの define) で作った CPU (実体は target/ 以下の struct CPUARMState など) は、全てグローバル変数 first_cpu から作った順番に辿ることができる。

最初の CPU が cpu_index == 0 で、順番に全て番号が付いているので、番号で識別できる。

cpu_single_env も似たような感じに使われているけど、これは cpu-exec.c の cpu_exec 関数の内部だけで有効。

686    /* fail safe : never use cpu_single_env outside cpu_exec() */
687    cpu_single_env = NULL;
688    return ret;
689}
ここらへんからも、QEMU はマルチスレッド対応が考えられていないことがわかる。
/* 'pc' is the host PC at which the exception was raised. 'address' is
   the effective address of the memory exception. 'is_write' is 1 if a
   write caused the exception and otherwise 0'. 'old_set' is the
   signal set which should be restored */
static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
                                    int is_write, sigset_t *old_set,
                                    void *puc)
{
    TranslationBlock *tb;
    int ret;

    if (cpu_single_env)
        env = cpu_single_env; /* XXX: find a correct solution for multithread */

0 件のコメント:

コメントを投稿