protsessi kood kahend süsteemis.
https://www.youtube.com/watch?v=trQAn9J0Q4E
kasutaja lõimed :
POSIX Pthreads (lõimed)
Win32 threads (lõimed)
java threads (lõimed)
kerneli lõimed:
Windows XP/2000 (lõimed)
Solaris (lõimed)
Linux (lõimed)
Tru64 UniX (lõimed)
Mac OS X (lõimed)
ühe kerneli lõimega on seotud mitu kasutaja lõime .
näited:
Solaris Green threads (lõimed)
GNU Portable threads (lõimed)
iga kasutaja lõim on seotud kerneli lõimuga
(vt pilt 1.)
Näited:
Windows NT/XP2000
Linux
Solaris 9 and later
Kahe tasandiline mudel
(vt pilt 2.)
Näited:
IRIX
HP-UX
Tru64 UNIX
Solaris 8 and earlier
Lõime juhtumid:
Semantics of fork() and exec() system calls
Thread cancellation
Signal handling
Threads pools
Threads specific data
Scheduler activations
Semantics of fork() and exec()
Does fork() duplicate inly the calling thread or all threads?
Signal Handling
Thread Pools
single and multithreads protcess
Thread Specific Data
Allows each thread to have its own copy of data
Usefull when you do not have control over the thread
creation process (i.e., when using a thread pool)
Benefits
Responsiveness
Resource Sharing
Economy
Utilization of MP Architectures
Pthreads
A POSIX standard (IEEE 1003.1c) API for threads
creation and synchroniceation
API specifies behavior of the thread
WIN XP threads ( lõimed )
Linux Threads
Linux refers to them as tasks rather than threads
Thread creation is done throught clone() system call
Clone() allows a child dask to share the address space of the parent task (process)
Java threads
java threads are managed by the JVM
Java threads may be created by:
Extending thread class
Implemending the Runnable interface
Interprocess Comunication
- Interprocess cumunication
- deadlocks
- Classic IPC Problems
Producer - Consumer Problem
Buffer is shared (ie., it is a shared variable)
Progress in time ....
Both processes are started at the sa,e time and consumer ases some old value initially
A race Condition
Because of the timing and wich process starts fisrt
Critical Sections
Critical sections
a section of code in which the process acesses and modifies shared variables
Mutal Exclusion
A method of preventing for ensuring that one of are in a critical sections
Mutal exclusin Problem starvation
Defination
indefinitely delaying the scheuling of a process in favor of other processes
Cause
Usually a bias in a sustem scheluling policies
solution
implement some from a again
Another Problem Deadlocks
More on semaphores
• Two types of semaphores
- binary semaphores can only be 0 or 1
- counting semaphores can be any non-negative integer
- binary semaphores can only be 0 or 1
- counting semaphores can be any non-negative integer
• Semaphores are an OS service implemented using one of the methods shown early
-usually by disabling interrupts for a very short time
-usually by disabling interrupts for a very short time
What is deadlock?
• process deadlock
-a process is deadlocked when it is waiting on an event which will never happen
-a process is deadlocked when it is waiting on an event which will never happen
•system deadlock
- a system is deadlocked when one or more processes are deadlocked
- a system is deadlocked when one or more processes are deadlocked
Necessary conditions for a deadlock
• mutal exclusion
-shared resources are used in a mutually exclusive manner
-shared resources are used in a mutually exclusive manner
• hold & wait
-processes hold onto resources they already have while waiting for the allocation of other resources
-processes hold onto resources they already have while waiting for the allocation of other resources
no preemption
resources can not be preemted until the process releases them
circular wait
a circular chain of processes exists in which each process holds recoursec wanted by the next process in the chain
No deadlock situations
if you can prevent at least one of the necessary deadlock conditions then you won't have a deadlock.
Denying " no problem "
implementation
- when a process is refused a resources request, i MUST release all other resourses it holds
- Reousurses can be removed from a process before it is finished with them
Advantages
- it works
- bossibly better resource utilization
Problems
- the cost of removing a process' resources
- the process is likely to lose work it has done
- possibility of starvation
Kommentaare ei ole:
Postita kommentaar