Multithreading performance concern

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Ycep
Member
Member
Posts: 401
Joined: Mon Dec 28, 2015 11:11 am

Multithreading performance concern

Post by Ycep »

Before I write this in assembly, would this take less than a milisecond on 300mhz CPU?

(If MOV takes 1 cycle and CMP & JMP 2 cycles)

Code: Select all

void Scheduler()
{
	if(TickLeft)return;
	curThread.type=READY_THREAD;
	Thread thr=Pop();
	if(thr.type==READY_THREAD)
	{
		thr.type=EXECUTING_THREAD;
		if(ThreadAmount<14)TickLeft=Optimizer[ThreadAmount];
		else TickLeft=1000/ThreadAmount;
		curThread=thr;
	}
}
The best answer I could hear is less than 300ns on 300mhz.
mallard
Member
Member
Posts: 280
Joined: Tue May 13, 2014 3:02 am
Location: Private, UK

Re: Multithreading performance concern

Post by mallard »

Which "300Mhz" CPU?

A 300Mhz ARM is going to be a lot slower than a 300Mhz Pentium II or AMD K7 (and even those will have different performance). There's also going to be the factor or RAM(/cache) performance, since even if the rest of the variables fit into registers "Optimizer[ThreadAmount]" will almost certainly use RAM.

It seems that this pseudo-C code amounts to less than 20 x86 instructions with 2 probable RAM fetches. None of those simple instructions will take more than 5 cycles on a Pentium II and there's nothing likely to trip up instruction prefetch. That seems to be congruent with your 300ns estimate; assuming both RAM fetches are cache-misses and you have PC100 SDRAM, that's another ~20ns. So, yes, well under 1ms on a typical x86 CPU of 300Mhz.
Image
User avatar
Ycep
Member
Member
Posts: 401
Joined: Mon Dec 28, 2015 11:11 am

Re: Multithreading performance concern

Post by Ycep »

@mallard : Hell yeah!
That is actually good since there needs to be space for priority based tasks (group of threads).
Is 200hZ for this scheduler realiable enough?
Post Reply