0

Maybe this is a stupid question but I am trying to gain a better understanding of hardware inner workings...

if a cpu has multi threads and we have a group of instruction set to assign it. as i read how it work from http://www.lighterra.com/papers/basicinstructionscheduling/ link. it says compiler will create a dependency tree of instructions and than instructions will run in parallel.how cpu will know dependent instruction has been finished or not. will it increase complexity.

i write a c code to see this

int main()
{
getchar();
putchar('a'); 
return 0;    
}

i think that instructions of getchar() and putchar() are independent and when i am not giving input from keyboard than on other thread instructions of putchar('a') should be executed and it should show output before asking for input. but it wait fist for input all time.

thanks in advance.

1 Answers1

0

That article mentions the CDC 6600, one of the first computers to implement scoreboarding .

rcgldr
  • 27,407
  • 3
  • 36
  • 61
  • can two thread execute different process instructions simultaneously. – Akash Chaudhary Aug 29 '15 at 16:28
  • Each core on a multi-core processor can run in parallel and has it's own set of registers. In the case of a single thread / single core situation, some instructions can be run in parallel and out of order, using scoreboarding to prevent conflicts between reads and writes of registers. I don't know if this also applies to memory based variables. The comment about the CDC 6600 compiler still applies to current optimized X86 compilers, some reordering of operations is done to reduce register scoreboarding delays. – rcgldr Aug 29 '15 at 16:35
  • and what about 1 core 2 thread . can two process run simultaneously. – Akash Chaudhary Aug 29 '15 at 16:39
  • As explained in this wiki article, it can be 2 processes, not just 2 threads. [hyper threading](http://en.wikipedia.org/wiki/Hyper-threading). – rcgldr Aug 29 '15 at 16:48
  • once _compiler_ _create_ a _assembly_ _code_ what happens after it .how this code run on hyper threading cpu. I have a lot of confusion on it. – Akash Chaudhary Aug 29 '15 at 16:49
  • Hyperthreading is used for separate processes or threads. What you probably want to know about is about parallel instructions in a single thread, which modern processors (and that CDC 6600) can perform, using scoreboarding to prevent read / write conflicts. – rcgldr Aug 29 '15 at 16:55
  • yes, I have confusion why we require dependency tree for instructions.how parallel instructions execute.they execute on different threads. please refer me appropriate link that explains these. – Akash Chaudhary Aug 29 '15 at 17:07
  • @AkashChaudhary - each thread has it's own set of registers, stack, ... so there's no need for a dependency tree or scoreboarding. Synchronization methods may be needed if threads or processes share data, but that's a separate issue. The issue here is a single thread with a single set of registers (which may be shadowed internally). – rcgldr Aug 29 '15 at 20:55