Using threads it is possible to organize the execution of a program in such a

Using threads it is possible to organize the

This preview shows page 36 - 38 out of 102 pages.

wrote the program does know. Using threads it is possible to organize the execution of a program in such a way that something is always being done, when ever the scheduler gives the heavyweight process CPU time. Threads allow a programmer to switch between lightweight processes when it is best for the program. (The programmer has control.) A process which uses threads does not get more CPU time than an ordinary process - but the CPU time it gets is used to do work on the threads. It is possible to write a more efficient program by making use of threads. Inside a heavyweight process, threads are scheduled on a FCFS basis, unless the program decides to force certain threads to wait for other threads. If there is only one CPU, then only one thread can be running at a time. Threads context switch without any need to involve the kernel - the switching is performed by a user level library, so time is saved because the kernel doesn't need to know about the threads.
Image of page 36
4.3.3 Levels of threads In modern operating systems, there are two levels at which threads operate: system or kernel threads and user level threads. If the kernel itself is multithreaded, the scheduler assigns CPU time on a thread basis rather than on a process basis. A kernel level thread behaves like a virtual CPU, or a power-point to which user-processes can connect in order to get computing power. The kernel has as many system level threads as it has CPUs and each of these must be shared between all of the user-threads on the system. In other words, the maximum number of user level threads which can be active at any one time is equal to the number of system level threads, which in turn is equal to the number of CPUs on the system. Since threads work ``inside'' a single task, the normal process scheduler cannot normally tell which thread to run and which not to run - that is up to the program. When the kernel schedules a process for execution, it must then find out from that process which is the next thread it must execute. If the program is lucky enough to have more than one processor available, then several threads can be scheduled at the same time. Some important implementations of threads are The Mach System / OSF1 (user and system level) Solaris 1 (user level) Solaris 2 (user and system level) OS/2 (system level only) NT threads (user and system level) IRIX threads POSIX standardized user threads interface 4.3.4 Symmetric and asymmetric multiprocessing Threads are of obvious importance in connection with parallel processing. There are two approaches to scheduling on a multiprocessor machine: Asymmetric : one CPU does the work of the system, the other CPUs service user requests. Symmetric : All processors can be used by the system and users alike. No CPU is special. The asymmetric variant is potentially more wasteful, since it is rare that the system requires a whole CPU just to itself. This approach is more common on very large machines with many processors, where the jobs the system has to do is quite difficult and warrants a CPU to itself.
Image of page 37
Image of page 38

You've reached the end of your free preview.

Want to read all 102 pages?

  • One '20

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors