google / ghost-userspace

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can i check the application actually run on the ghost?

cashey opened this issue · comments

1.I get the pid of the application
2.run the ghost agent
3.then run the command echo PID > /sys/fs/ghost/enclave_1/tasks
by the three step, i think i run the appication on the ghost, but i want check it whether it actually run on the ghost agent? how can i do?
thanks ,very much!

You are correct -- after step 3, the application thread with TID PID has been moved to the ghOSt scheduling class and is assigned to enclave 1. To be clear, writing PID to the tasks file just moves the thread with TID PID to ghOSt; this does not move all threads in the application with PID PID to ghOSt.

You can check that the application thread has been moved to ghOSt in a couple of ways:

  1. Ensure that a TASK_NEW message is delivered to the ghOSt agent:
void Scheduler::TaskNew(Task* task, const Message& msg) {
  const ghost_msg_payload_task_new* payload =
      static_cast<const ghost_msg_payload_task_new*>(msg.payload());

  const Gtid gtid(payload->gtid);
  printf("New Task TID: %d\n", gtid.tid());

  ...
}

The TID printed by the method should match PID.

  1. In the application thread, check that the thread's scheduler is ghOSt:
int scheduler = sched_getscheduler(/*pid=*/0);
if (scheduler == SCHED_GHOST) {
  printf("This thread is scheduled by ghOSt.\n");
} else {
  printf("This thread is not scheduled by ghOSt.\n");
}