Page 122 - Computer_Science_F5
P. 122

(e)  Multithreaded programs can  (c)  It is important that in SMT, the OS
                   potentially scale well with increasing   does not make the mistake of treating
                   numbers of processors. By distributing   all threads equal, even if some come
                   tasks across multiple cores, workloads   from different cores. This can lead
                   can be completed faster.                 to inefficient workload distribution.
          FOR ONLINE READING ONLY
                                                            Imagine a restaurant manager           Chapter Two: Performance and optimisation of computer processor
              Challenges of multithreading                  assigning all tasks to the same waiter,
              (a)  Register conflicts: Instructions from    even when others are free.
                   different threads might use the same
                   register names, requiring techniques  Examples of SMT architectures
                   like register renaming to avoid data
                   corruption.                         (a) Intel Hyperthreading (HT)
              (b)  Program counter management: Each    Launched in 2002, Hyperthreading was a
                   thread has its own program counter   revolutionary technology that transformed
                   (PC) keeping track of its execution   single-core Pentium 4 processors into
                   position.                           logical dual-core processors from the
              (c)  Virtual memory management: The      operating system’s perspective. Each
                   operating system needs to manage    physical core houses two architectural
                   memory access for multiple threads   sets, essentially creating two logical cores
                   within a process and potentially    for the OS.
                   across multiple processes.
                                                       These sets have their own:
                                                        (i)  General-purpose registers: Used to
              Considerations when designing SMT-
              enabled processors:                           store temporary data during program
                                                            execution.
              (a)  SMT works well if threads are
                   well-behaved: There are not too      (ii)  Control registers: Manage the state
                   many demanding threads, and they         of the processor and execution flow.
                   use different processing resources   (iii) Interrupt control registers: Handle
                   (like doing both math and graphics       hardware interrupts and exceptions.
                   calculations). Think of it like having   (iv)  Machine state registers:  Track
                   a team of specialists who do not all     various processor settings and
                   need the same tools at once.             configurations.

              (b)  SMT works well if there is harmony   (v)  Benefits:     Hyperthreading
                   in the workload: Threads do not fight    significantly improved performance
                   over the same resources in the core,     for workloads that could benefit from
                   allowing for smooth execution.           TLP (Thread-Level Parallelism).
                   Imagine chefs in a kitchen with          Applications like web browsing,
                   separate chopping boards and stoves,     multitasking, and media processing
                   minimising bottlenecks.                  saw a noticeable boost.

                                                    113
               Student’s Book  Form Five



     Computer Science Form 5.indd   113                                                     23/07/2024   12:33
   117   118   119   120   121   122   123   124   125   126   127