Presentation is loading. Please wait.

Presentation is loading. Please wait.

Procesi in niti pri Windows NT. Procesi in niti Primeri sistemskih niti.

Similar presentations


Presentation on theme: "Procesi in niti pri Windows NT. Procesi in niti Primeri sistemskih niti."— Presentation transcript:

1 Procesi in niti pri Windows NT

2 Procesi in niti

3 Primeri sistemskih niti

4 4 konteksti izvajanja kode

5 Procesi in niti The process has a virtual memory address space, information (such as a base priority), and an affinity for one or more processors. Threads are the unit of execution scheduled by the kernel’s dispatcher. Each thread has its own state, including a priority, processor affinity, and accounting information. A thread can be one of six states: ready, standby, running, waiting, transition, and terminated.

6 Proces Opisniki virtualnega naslovnega prostora...... Handle 1 Handle 2 Handle 3 Tabela ročic do objektov Thread x File y Sekcija z Objekti, z dovoljenim dostopom... Dostopni žeton

7 Virtual address space (including program global storage, heap storage, threads’ stacks)  processes cannot corrupt each other’s address space by mistake Working set (physical memory “owned” by the process) Access token (includes security identifiers) Handle table for Win32 kernel objects These are common to all threads in the process, but separate and protected between processes Vsak proces ima svoje lastno…

8 Vsaka nit ima svoj … Stack (automatic storage, call frames, etc.) Instance of a top-level function Scheduling state (Wait, Ready, Running, etc.) and priority Current access mode (user mode or kernel mode) Saved CPU state if it isn’t Running Access token (optional -- overrides process’s if present)

9 Kernel — razvrščanje The dispatcher uses a 32-level priority scheme to determine the order of thread execution. Priorities are divided into two classes. – The real-time class contains threads with priorities ranging from 16 to 31. – The variable class contains threads having priorities from 0 to 15. Characteristics of XP’s priority strategy. – Trends to give very good response times to interactive threads that are using the mouse and windows. – Enables I/O-bound threads to keep the I/O devices busy. – Complete-bound threads soak up the spare CPU cycles in the background.

10 Kernel — razvrščanje (nadaljevanje.) Scheduling can occur when a thread enters the ready or wait state, when a thread terminates, or when an application changes a thread’s priority or processor affinity. Real-time threads are given preferential access to the CPU; but XP does not guarantee that a real-time thread will start to execute within any particular time limit. (This is known as soft realtime.)

11 Programmer Interface — Process Management Process is started via the CreateProcess routine which loads any dynamic link libraries that are used by the process, and creates a primary thread. Additional threads can be created by the CreateThread function. Every dynamic link library or executable file that is loaded into the address space of a process is identified by an instance handle.

12 Process Management (Cont.) Scheduling in Win32 utilizes four priority classes: -IDLE_PRIORITY_CLASS (priority level 4) -NORMAL_PRIORITY_CLASS (level8 — typical for most processes -HIGH_PRIORITY_CLASS (level 13) -REALTIME_PRIORITY_CLASS (level 24) To provide performance levels needed for interactive programs, XP has a special scheduling rule for processes in the NORMAL_PRIORITY_CLASS. – XP distinguishes between the foreground process that is currently selected on the screen, and the background processes that are not currently selected. – When a process moves into the foreground, XP increases the scheduling quantum by some factor, typically 3.

13 Process Management (Cont.) The kernel dynamically adjusts the priority of a thread depending on whether it is I/O-bound or CPU-bound. To synchronize the concurrent access to shared objects by threads, the kernel provides synchronization objects, such as semaphores and mutexes. – In addition, threads can synchronize by using the WaitForSingleObject or WaitForMultipleObjects functions. – Another method of synchronization in the Win32 API is the critical section.

14 Process Management (Cont.) A fiber is user-mode code that gets scheduled according to a user-defined scheduling algorithm. – Only one fiber at a time is permitted to execute, even on multiprocessor hardware. – XP includes fibers to facilitate the porting of legacy UNIX applications that are written for a fiber execution model.

15 Processes and Threads (1) Basic concepts used for CPU and resource management

16 Processes and Threads (2) Relationship between jobs, processes, threads, and fibers

17 Razvrščanje pri Windows 2000 Windows 2000 schedules at the thread granularity. Priority-driven, preemptive scheduling system – The highest-priority runnable thread always runs. – Time-sliced, round-robin within a priority level. Windows 2000 uses 32 priority levels – System level (0), Variable levels (1-15), Real-time levels (16-31) From Win32 point of view – Processes are given a priority class upon creation: » Idle, Below Normal, Normal, Above Normal, High, Real-time » Changeable by Task Manager. – The individual threads have a relative priority within the class: » Idle, Lowest, Below-Normal, Normal, Above Normal, Highest, Time-Critical

18 Prioritete jedra pri Windows 2000

19 Scheduling (1) Mapping of Win32 priorities to Windows 2000 priorities

20 Scheduling (2) Windows 2000 supports 32 priorities for threads

21 An example of priority inversion Scheduling (3)

22 Job, Process, Thread & Fiber Mgmt. API Calls Some of Win32 calls for managing processes, threads and fibers

23 CPE je zasedena – zakaj le?

24 Kateri proces teče?

25 Process explorer (Sysinternals) Process tree If left justified, parent has exited Disappears if you sort by any column Bring back with View->Show Process Tree Additional details in process list Icon and description (from.EXE) User Name shows domain name Highlight Own, Services Processes Differences highighting Green: new, Red: gone View->Update speed->Paused

26 32 bitni virtualni naslovni prostor (x86)

27 Proces in uporaba pomnilnika: “delovna množica”

28 Zamenjava delovne množice

29 Podatki o pomnilniku za proces

30 Souporabljen pomnilnik

31 Vpogled v delovne množice

32 Življenje servisa


Download ppt "Procesi in niti pri Windows NT. Procesi in niti Primeri sistemskih niti."

Similar presentations


Ads by Google