tailieunhanh - distributed operating system phần 4

Tuy nhiên, các thông tin trong cuốn sách này được bán mà không có sự bảo đảm, thể hiện rõ ràng hay ngụ ý. Không phải là tác giả, xuất bản Packt, cũng không phải các đại lý hoặc nhà phân phối sẽ được tổ chức chịu trách nhiệm về bất kỳ thiệt hại gây ra | 178 PROCESSES AND PROCESSORS IN DISTRIBUTED SYSTEMS CHAP. 4 Alternatively new library procedures can be introduced to create set and read these thread-wide global variables. The first call might look like this create_global C bufptr It allocates storage for a pointer called bufptr on the heap or in a special storage area reserved for the calling thread. No matter where the storage is allocated only the calling thread has access to the global variable. If another thread creates a global variable with the same name it gets a different storage location that does not conflict with the existing one. Two calls are needed to access global variables one for writing them and the other for reading them. For writing something like set_global bufptr buf will do. It stores the value of a pointer in the storage location previously created by the call to create-global. To read a global variable the call might look like bufptr read-global C bufptr This call returns the address stored in the global variable so the data value can be accessed. Our last design issue relating to threads is scheduling. Threads can be scheduled using various scheduling algorithms including priority round robin and others. Threads packages often provide calls to give the user the ability to specify the scheduling algorithm and set the priorities if any. . Implementing a Threads Package There are two main ways to implement a threads package in user space and in the kernel. The choice is moderately controversial and a hybrid implementation is also possible. In this section we will describe these methods along with their advantages and disadvantages. Implementing Threads in User Space The first method is to put the threads package entirely in user space. The kernel knows nothing about them. As far as the kernel is concerned it is managing ordinary single-threaded processes. The first and most obvious advantage is that a user-level threads package can be implemented on an operating system that does not .

TỪ KHÓA LIÊN QUAN