Ағылшыншамен салыстырыңыз: абзацты басыңыз — түпнұсқа терезеде ашылады. Абзац астындағы EN түймесі оны мәтін ішінде көрсетеді.
Мазмұны
Кіріспе
Native POSIX Thread Library (NPTL) — Linux операциялық жүйесі үшін POSIX Threads спецификациясының іске асырылуы.
The Native POSIX Thread Library (NPTL) is an implementation of the POSIX Threads specification for the Linux operating system.
Тарих
Linux ядросының 2.6 нұсқасына дейін процестер жоспарланатын объектілер болды және жіптер (threads) үшін ешқандай арнайы мүмкіндіктер болмады. Дегенмен, оның жүйелік шақыруы бар — , ол шақырушы процестің көшірмесін жасайды, мұнда көшірме шақырушының адрестік кеңістігін бөліседі. LinuxThreads жобасы осы жүйелік шақыруды ядро деңгейіндегі жіптерді қамтамасыз ету үшін пайдаланды (Linux-тағы бұрынғы жіптік іске асырулардың көпшілігі пайдаланушы кеңістігінде (userland) толыққанды жұмыс істеді). Өкінішке орай, ол POSIX стандартына толыққанды сәйкес келмеді, әсіресе сигналдарды өңдеу, жоспарлау және процестер аралық синхронизация примитивтері саласында. LinuxThreads-ті жақсарту үшін ядролық қолдау және жаңа жіптік кітапхана қажет екені анық болды. Бұл қажеттілікті қанағаттандыру үшін екі бәсекелес жоба басталды: NGPT (Next Generation POSIX Threads) IBM әзірлеушілерін қамтитын командамен жұмыс істеді, ал NPTL Red Hat әзірлеушілерімен жұмыс істеді. NGPT тобы NPTL тобымен тығыз байланыста жұмыс істеді және екі іске асырудың ең жақсы мүмкіндіктерін NPTL-ге біріктірді. NGPT жобасы 2003 жылдың ортасында NPTL-ге ең жақсы мүмкіндіктерін қосып бітіргеннен кейін тоқтатылды. NPTL алғаш рет Red Hat Linux 9-да жарық көрді. Ескі үлгідегі Linux POSIX жіптері жүйеге уақытша берілуден бас тартатын жіптермен қиындықтарға тап болатын, себебі ол пайда болған кезде оларды алдын ала тоқтату мүмкіндігін пайдаланбады, бұл кезде Windows мұны жақсырақ істегені белгілі. Red Hat компаниясы NPTL бұл мәселені Red Hat Linux 9 жүйесінде Java туралы Java веб-сайтындағы мақаласында шешкенін мәлімдеді. NPTL Red Hat Enterprise Linux-тың 3-ші нұсқасынан бастап және Linux ядросының 2.6 нұсқасынан бастап қолданысқа енді. Қазір ол GNU C кітапханасының толыққанды біріктірілген бөлігі. NPTL үшін POSIX Thread Trace Tool (PTT) деп аталатын іздеу құралы бар. Сондай-ақ, NPTL кітапханасын POSIX стандартына сәйкестігін тексеру үшін Open POSIX Test Suite (OPTS) жазылды.
Before the 2.6 version of the Linux kernel, processes were the schedulable entities, and there were no special facilities for threads. However, it did have a system call — — which creates a copy of the calling process where the copy shares the address space of the caller. The LinuxThreads project used this system call to provide kernel level threads (most of the previous thread implementations in Linux worked entirely in userland). Unfortunately, it only partially complied with POSIX, particularly in the areas of signal handling, scheduling, and inter process synchronization primitives. To improve upon LinuxThreads, it was clear that some kernel support and a new threading library would be required. Two competing projects were started to address the requirement: NGPT (Next Generation POSIX Threads) worked on by a team which included developers from IBM, and NPTL by developers at Red Hat. The NGPT team collaborated closely with the NPTL team and combined the best features of both implementations into NPTL. The NGPT project was subsequently abandoned in mid 2003 after merging its best features into NPTL. NPTL was first released in Red Hat Linux 9. Old style Linux POSIX threading is known for having trouble with threads that refuse to yield to the system occasionally, because it does not take the opportunity to preempt them when it arises, something that Windows was known to do better at the time. Red Hat claimed that NPTL fixed this problem in an article on the Java website about Java on Red Hat Linux 9. NPTL has been part of Red Hat Enterprise Linux since version 3, and in the Linux kernel since version 2.6. It is now a fully integrated part of the GNU C Library. There exists a tracing tool for NPTL, called POSIX Thread Trace Tool (PTT). And an Open POSIX Test Suite (OPTS) was written for testing the NPTL library against the POSIX standard.
Дизайн
LinuxThreads сияқты, NPTL – 1:1 жіптер кітапханасы. Кітапхана арқылы құрылған жіптер (pthread create арқылы) ядродағы жоспарланатын бірліктермен (Linux жағдайында процестермен) бір-бірге сәйкес келеді. Бұл үш жіптеу моделінің (1:1, N:1 және M:N) ең қарапайым түрі. Жаңа жіптер clone жүйелік шақыру арқылы, NPTL кітапханасы арқылы жасалады. NPTL пайдаланушы кеңістігіндегі құлыптамаларды тиімдірек жүзеге асыру үшін ядроның futex қолдауына сенеді.
Like LinuxThreads, NPTL is a 1:1 threads library. Threads created by the library (via pthread create) correspond one to one with schedulable entities in the kernel (processes, in the Linux case). This is the simplest of the three threading models (1:1, N:1, and M:N). New threads are created with the clone system call called through the NPTL library. NPTL relies on kernel support for futexes to more efficiently implement user space locks.