Page 74 - DCAP103_Principle of operating system
P. 74

Unit 3: Process Management-II



            cheap and widely available. Most operating systems have support for SMP (Symmetric Multi-  Notes
            Processing), and IDL users are beginning to own such hardware. In the future, it is reasonable
            to imagine that most machines will have multiple CPUs.

            The multi-threading capability, first added in IDL 5.5, applies to binary and unary operators,
            many  core  mathematical  functions,  and  a  number  of  image  processing,  array  manipulation
            and type conversion routines. Although performance results will vary, the execution time of
            these  computations  can  be  significantly  reduced  on  systems  with  multiple  processors.  The
            ability to exploit multiple CPUs will become very important in coming years, and the list of
            threaded routines is expected to grow with each release of IDL. IDL users should be aware that
            ITT-VIS offers a Global Services Group (GSG) that can be hired to help optimize user-written
            code or to parallelize specific algorithms beyond those that use the thread pool. The interface
            for  controlling  the  IDL  thread  pool  is  simple,  allowing  immediate  and  measurable  benefits
            with little effort. In addition, the IDL thread pool is safe and transparent on platforms that are
            unable to support threading. Those platforms that can benefit will use threads, and those that
            cannot will continue to produce correct results using a single thread, and with the same level
            of performance as previous versions of IDL. This unit provides background and motivation for
            IDL’s multi-threading capability.
            3.3.1 Multi-threading

            The concept of multi-threading involves an operating system that is multi-thread capable
            allowing programs to split tasks between multiple execution threads. On a machine with multiple
            processors, these threads can execute concurrently, potentially speeding up the task significantly.
            Mathematical computations on large amounts of scientific data can be quite intensive and are
            ideal candidates for threading on systems with multiple CPUs.

            The most common type of program is the single-threaded program. IDL has traditionally been
            single-threaded. When the program runs, this single thread starts at the main( ) function in the
            program, and runs until it either exits, or performs an illegal operation and is killed by the
            operating system. Since it is the only thread, it knows that anything that happens in this program
            is caused solely by it. Most modern operating systems time slice between various programs, so at
            any given time, a single thread is either running or sleeping. There are two reasons why it may
            be sleeping—It is waiting for a needed, but currently unavailable resource (e.g. memory, data
            (input, output)...). The operating system is letting some other program run. This time slicing,
            which is usually preemptive multitasking, happens so quickly that the end user is fooled into
            thinking that everything is running simultaneously.
            To move from single-threaded to multi-threaded (MT) programs requires a small conceptual
            generalization of the above. Instead of having only a single thread, we allow more than one
            thread in a single process. Each thread has its own program counter and stack, and is free to run,
            unimpeded by any other thread in the same program. All threads in the same program share any
            other resources, including code, data, and open files. The operating system still schedules which
            threads run and when, but instead of scheduling by process, it now schedules the individual
            threads within a process. If your system has a single CPU, preemptive multitasking still gives
            the illusion that more than one thing is going on simultaneously. If the system has more than
            one CPU, then more than one thread can be running on the system at a given time. It is even
            possible that more than one thread within a given program will run simultaneously. This is
            actual simultaneous execution, not the mere illusion of it as with a uniprocessor. It is important
            to realize that the software concept of threading is an abstraction provided by the operating
            system, and it is available whether or not the underlying hardware has multi-processing (MP)
            capabilities.  It  is  reasonable  to  run  a  MT  program  on  a  uniprocessor,  unless  your  program
            requires actual simultaneous execution of multiple threads to work properly. For example, a
            program might use a thread to wait for incoming data from a slow source, while other threads


                                             LOVELY PROFESSIONAL UNIVERSITY                                    67
   69   70   71   72   73   74   75   76   77   78   79