google / ghost-userspace

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to get scheduled threads information with shinjuku scheduler ?

NGUETOUM opened this issue · comments

Hello, Please excuse me i have a problem and it is not error during the scheduler execution but i need to have please more explanation about some event that i have observe.
I have reach to make threads migration during the execution of shinjuku scheduler by setting my threads in my userspace application on a PrioTable as @jackhumphries had tell me.
But when the threads has migrated, i just get information about ShinjukuSchedParams not some information about threads state an so on as you can see on this image:

image

I think that this is because the following instruction on shinjuku_scheduler.cc inside the DumpAllTask() method is never execute:

allocator()->ForEachTask([](Gtid gtid, const ShinjukuTask* task) {
absl::FPrintF(stderr, "%-12s%-12s%c\n", gtid.describe(),
ShinjukuTask::RunStateToString(task->run_state),
task->prio_boost ? 'P' : '-');
return true;
});

To reach to execute this method i have just change this instruction global_scheduler_->debug_runqueue_ = false; to global_scheduler_->debug_runqueue_ = true; as you can see in the following image:
image

Please someone can tell me what i am suppose to do before to execute that instruction for getting those information about threads state?

Hello,

My understanding is that you are asking how to get the Shinjuku scheduler to print debug information about the tasks. To do so, you need to send a SIGUSR1 signal to the Shinjuku scheduler process while it is running.

To send this signal, first get the PID of the Shinjuku process using ps -aux. Note that you will see two Shinjuku processes: one of them is the process you directly launched while the second is a process forked by the first. Choose the first process, i.e., the one with the lower PID. Then issue the command below, replacing pid with the first process's PID:

kill -s USR1 pid

Please let me know if you have additional questions.

Ok Sir. I apply it now and thank so much for your presence.

Please Sir I get the same thing during the execution after applying your instruction.

image

It not print the information about thread infos

I don't know if the problem come from the script that I use to make thread migration?
This is the script Sir
shinjuku_test.cc.txt

From what you posted, my understanding is that your concern is that allocator()-> ForEachTask() { ... } is not printing thread state. I took a quick look at your code and it seems like all four threads are being spawned and then exiting very quickly. Thus, it is likely that all threads are dead before the allocator()->ForEachTask() runs which is why nothing is printed about them (because the threads do not exist anymore), though the shared memory PrioTable persists which is why you see that printed.

If you run agent_shinjuku with verbose mode on (e.g., --verbose 3), do see you messages about the threads being printed? Are any messages still being printed when you would expect allocator()->ForEachTask() to also print thread state?

Now I get the MESSAGE about task when I set verbosity to 3 as you have say:

image

But Sir it is possible to get explicit information such as Fifo scheduler. Because my objective is to see how shinjuku scheduler perform scheduling, how it manage tasks and how it operate.

But It not print threads state

It is ok now Sir.

As you have say that the allocator()->ForEachTask() don't print nothing because before that this function is execute all those threads have finish their execution. I have modify the function executed by each thread in the script that I show you by apply sleep(3) after each printf in that function and now the scheduler print the state of each thread as you can see in this image:

image

There I have modify the code to create 10 threads Sir this is why you can see that the number of threads have add.

But Sir I have another preoccupation, I want to know if all those threads are executed in order ? they have the same priority ? And if yes if I want to change the thread priority on shed_item before to spawn those threads how i am suppose to do since the struct shed_item don't contain priority variable ?

Hi, @jackhumphries
Thanks so much for your help, it is OK for me and now I reach to print information about threads state during scheduling normally. Thanks.

Glad you got it working. The threads are scheduled in round-robin order and each thread's priority is determined by the QoS value of the work class it is in. If you would like the scheduler to make different policy decisions or have access to more information about the threads, you will need to modify the code.

Ok Sir, and thanks so much.