Procese, fire. Sistemul de fişiere

Transcription

Procese, fire. Sistemul de fişiere
3. SO Windows
3.1.Principii de proiectare
3.2. Structura. Componente
3.3. Comenzi
3.4. Registry
3.5. Gestiunea memoriei
3.6. Procese si fire
3.7. Sistemul de fisiere
3.8. Interfata de programare
3.9. Componente de retea
Conf.dr.Carmen Timofte
Sisteme de operare
1
3.6. Procese si fire
KERNEL
o Foundation for the executive and the subsystems
o Never paged out of memory; execution is never preempted
o Four main responsibilities:
o thread scheduling
o interrupt and exception handling
o low-level processor synchronization
o recovery after a power failure
o Kernel is object-oriented, uses two sets of objects
o dispatcher objects control dispatching and synchronization (events, mutants, mutexes, semaphores, threads
and timers)
o control objects (asynchronous procedure calls, interrupts, power notify, power status, process and profile
objects)
Conf.dr.Carmen Timofte
Sisteme de operare
2
1
(*)
(*) Relatia dintre job-uri (task), procese, fire (threads), fibre (fibers)
Conf.dr.Carmen Timofte
Sisteme de operare
3
(*) Some of Win32 calls for managing processes, threads and fibers
Conf.dr.Carmen Timofte
Sisteme de operare
4
2
(*) Kernel Scheduling (Planificatorul)
o Dispecerul utilizează o schemă cu 32 nivele de priorităţi pt. a determina ordinea de
execuţie a firelor;
o Priorităţile sunt divizate în 2 clase:
o Clasa în timp-real – conţine fire cu priorităţi între 16-31;
o Clasa variabilă – pt. priorităţi între 0-15;
o Planificarea are loc atunci când:
o firul intră în starea “ready” sau “wait”,
o se termină
o aplicaţia schimbă prioritatea firului sau a procesorul alocat;
o Firele în timp-real au acces preferenţial la CPU => realtime soft = XP nu garantează că
acel fir va începe execuţia fără restricţii particulare de timp;
Conf.dr.Carmen Timofte
Sisteme de operare
5
(*) Prioritati
Mapping of Win32 priorities to Windows
2000 priorities
Windows 2000 supports 32 priorities for
threads
Windows XP Interrupt
Request Levels
Conf.dr.Carmen Timofte
Sisteme de operare
6
3
3.7. Sistemul de fisiere
o
o
o
The fundamental structure of the XP file system (NTFS) is a volume
o Created by the XP disk administrator utility
o Based on a logical disk partition
o May occupy a portions of a disk, an entire disk, or span across several disks
All metadata, such as information about the volume, is stored in a regular file
NTFS uses clusters as the underlying unit of disk allocation
o A cluster is a number of disk sectors that is a power of two
o Because the cluster size is smaller than for the 16-bit FAT file system, the amount of internal
fragmentation is reduced
Internal Layout
o
o
o
o
o
NTFS uses logical cluster numbers (LCNs) as disk addresses
A file in NTFS is not a simple byte stream, as in MS-DOS or UNIX, rather, it is a structured object
consisting of attributes
Every file in NTFS is described by one or more records in an array stored in a special file called the
Master File Table (MFT)
Each file on an NTFS volume has a unique ID called a file reference.
o 64-bit quantity that consists of a 48-bit file number and a 16-bit sequence number
o Can be used to perform internal consistency checks
The NTFS name space is organized by a hierarchy of directories; the index root contains the top level of
the B+ tree
Conf.dr.Carmen Timofte
Sisteme de operare
7
(*) Master File Table pt. NTFS
Atribute pt. inregistrarile MFT
Conf.dr.Carmen Timofte
Sisteme de operare
8
4
(*)
Recovery
o All file system data structure updates are performed inside transactions that are logged
• Before a data structure is altered, the transaction writes a log record that contains redo and undo
information
• After the data structure has been changed, a commit record is written to the log to signify that the
transaction succeeded
• After a crash, the file system data structures can be restored to a consistent state by processing the
log records
o This scheme does not guarantee that all the user file data can be recovered after a crash, just that the file
system data structures (the metadata files) are undamaged and reflect some consistent state prior to the
crash
o The log is stored in the third metadata file at the beginning of the volume
o The logging functionality is provided by the XP log file service
Security
o Security of an NTFS volume is derived from the XP object model
o Each file object has a security descriptor attribute stored in this MFT record
o This attribute contains the access token of the owner of the file, and an access control list that states the
access privileges that are granted to each user that has access to the file
Conf.dr.Carmen Timofte
Sisteme de operare
9
(*)
Volume Management and Fault Tolerance
o FtDisk, the fault tolerant disk driver for XP, provides several ways to combine multiple SCSI disk drives
into one logical volume
o Logically concatenate multiple disks to form a large logical volume, a volume set
o Interleave multiple physical partitions in round-robin fashion to form a stripe set (also called RAID level
0, or “disk striping”)
o Variation: stripe set with parity, or RAID level 5
o Disk mirroring, or RAID level 1, is a robust scheme that uses a mirror set — two equally sized partitions
on tow disks with identical data contents
o To deal with disk sectors that go bad, FtDisk, uses a hardware technique called sector sparing and NTFS
uses a software technique called cluster remapping
Compression
• To compress a file, NTFS divides the file’s data into compression units, which are blocks of 16
contiguous clusters
• For sparse files, NTFS uses another technique to save space
o Clusters that contain all zeros are not actually allocated or stored on disk
o Instead, gaps are left in the sequence of virtual cluster numbers stored in the MFT entry for the
file
o When reading a file, if a gap in the virtual cluster numbers is found, NTFS just zero-fills that
portion of the caller’s buffer
Conf.dr.Carmen Timofte
Sisteme de operare
10
5
3.8. Interfata de programare
Access to Kernel Obj
• A process gains access to a kernel object named XXX by calling the CreateXXX function to
open a handle to XXX; the handle is unique to that process
• A handle can be closed by calling the CloseHandle function; the system may delete the object
if the count of processes using the object drops to 0
• XP provides three ways to share objects between processes
o A child process inherits a handle to the object
o One process gives the object a name when it is created and the second process opens
that name
o DuplicateHandle function:
Given a handle to process and the handle’s value a second process can get a
handle to the same object, and thus share it
Conf.dr.Carmen Timofte
Sisteme de operare
11
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
o Scheduling in Win32 utilizes four priority classes:
o IDLE_PRIORITY_CLASS (priority level 4)
o NORMAL_PRIORITY_CLASS (level8 — typical for most processes
o HIGH_PRIORITY_CLASS (level 13)
o 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
o XP distinguishes between the foreground process that is currently selected on the screen, and the
background processes that are not currently selected
o When a process moves into the foreground, XP increases the scheduling quantum by some factor,
typically 3
• The kernel dynamically adjusts the priority of a thread depending on whether it is I/O-bound or CPUbound
• To synchronize the concurrent access to shared objects by threads, the kernel provides synchronization
objects, such as semaphores and mutexes
o In addition, threads can synchronize by using the WaitForSingleObject or
WaitForMultipleObjects functions
o Another method of synchronization in the Win32 API is the critical section
• A fiber is user-mode code that gets scheduled according to a user-defined scheduling algorithm
o Only one fiber at a time is permitted to execute, even on multiprocessor hardware
o XP includes fibers to facilitate the porting of legacy UNIX applications that are written for a fiber
execution model
(*) •
Conf.dr.Carmen Timofte
Sisteme de operare
12
6
(*)
Interprocess Comm.
• Win32 applications can have interprocess communication by sharing kernel objects
• An alternate means of interprocess communications is message passing, which is particularly
popular for Windows GUI applications
• One thread sends a message to another thread or to a window
• A thread can also send data with the message
• Every Win32 thread has its own input queue from which the thread receives messages
• This is more reliable than the shared input queue of 16-bit windows, because with separate
queues, one stuck application cannot block input to the other applications
Conf.dr.Carmen Timofte
Sisteme de operare
13
(*)
Memory Management
• Virtual memory:
o VirtualAlloc reserves or commits virtual memory
o VirtualFree decommits or releases the memory
These functions enable the application to determine the virtual address at which the memory
is allocated
• An application can use memory by memory mapping a file into its address space
o Multistage process
o Two processes share memory by mapping the same file into their virtual memory
• A heap in the Win32 environment is a region of reserved address space
o A Win 32 process is created with a 1 MB default heap
o Access is synchronized to protect the heap’s space allocation data structures from
damage by concurrent updates by multiple threads
• Because functions that rely on global or static data typically fail to work properly in a
multithreaded environment, the thread-local storage mechanism allocates global storage on a
per-thread basis
o The mechanism provides both dynamic and static methods of creating thread-local
storage
Conf.dr.Carmen Timofte
Sisteme de operare
14
7
3.9. Componente de retea
Protocoale de reţea
o Suportă comunicaţii:
o Peer-to-peer
o Client/server
o Suportă management de reţea;
o Suportă 2 interfeţe de reţea interne:
o NDIS (Network Device Interface Specification) – oferă adaptoare de reţea separate pt. protocoale de
transport, care pot fi schimbate fără a le afecta pe celelalte;
o TDI (Transport Driver Interface) – permite componentelor de nivel sesiune să folosească orice
mecanism de transport.
o Win (XP) implementează protocoalele de transport ca driver-e, care pot fi încărcate/descărcate dinamic
Conf.dr.Carmen Timofte
Sisteme de operare
15
(*) Protocoale de reţea
o
o
o
o
o
o
o
SMB (Server Message Block) is used to send I/O requests over the network. It has four
message types:
o Session control
o File
o Printer
o Message
NetBIOS (The network Basic Input/Output System) is a hardware abstraction interface for
networks, used to:
- Establish logical names on the network
- Establish logical connections of sessions between two logical names on the network
- Support reliable data transfer for a session via NetBIOS requests or SMBs
NetBEUI (NetBIOS Extended User Interface) default protocol for Windows 95 peer
networking and Windows for Workgroups; used when XP wants to share resources with
these networks; XP uses the TCP/IP Internet protocol to connect to a wide variety of
operating systems and hardware platforms
PPTP (Point-to-Point Tunneling Protocol) is used to communicate between Remote Access
Server modules running on XP machines that are connected over the Internet
The XP NWLink protocol connects the NetBIOS to Novell NetWare networks
The Data Link Control protocol (DLC) is used to access IBM mainframes and HP printers
that are directly connected to the network
XP systems can communicate with Macintosh computers via the Apple Talk protocol if an
XP Server on the network is running the Windows XP Services for Macintosh package
Conf.dr.Carmen Timofte
Sisteme de operare
16
8
(*) NetBIOS/NetBEUI
NetBIOS (Network Basic Input/Output System) a fost creat în 1984 de
IBM şi Sytek şi reprezintă o facilitate de comunicare între programele din
calculatoarele de tip PC care operează într-o reţea.
NetBIOS facilitează comunicarea prin trei servicii de bază: servicul de
nume, serviciul de sesiuni, serviciul de datagrame.
•NetBEUI (NetBIOS Extended
User Interface) - defineste
funcţiile din cadrul NetBIOS care
operează la nivelul protocolului de
comunicaţie, (diferenţierea între
acest nivel şi nivelul serviciilor.)
•SMB (System Message
Blocks), - facilităţi la nivelul
aplicaţie, necesare pentru
implementarea serviciilor de
partajare a fişierelor, de imprimare
sau a altor servicii orientate
utilizator.
Conf.dr.Carmen Timofte
Servicii fişiere, im primare, altele
Aplicaţie
Redirector
Prezentare
NetBIOS
Sesiu ne
Transport
TCP/IP
SPX/IPX
NetBEUI
Altele
Reţea
Gestionar Protocol
Driver NDIS
Legătura
de date
Fizic
Ethernet
Token Ring
T oken Bus
Sisteme de operare
Altele
17
(*) Distributed Processing Mechanisms
o XP supports distributed applications via named NetBIOS, named pipes and
mailslots, Windows Sockets, Remote Procedure Calls (RPC), and Network
Dynamic Data Exchange (NetDDE)
NetBIOS applications can communicate over the network using NetBEUI,
NWLink, or TCP/IP
Named pipes are connection-oriented messaging mechanism that are
named via the uniform naming convention (UNC)
Mailslots are a connectionless messaging mechanism that are used for
broadcast applications, such as for finding components on the network
Winsock, the windows sockets API, is a session-layer interface that
provides a standardized interface to many transport protocols that may have
different addressing schemes
The XP RPC mechanism follows the widely-used Distributed Computing
Environment standard for RPC messages, so programs written to use XP
RPCs are very portable
• RPC messages are sent using NetBIOS, or Winsock on TCP/IP
networks, or named pipes on LAN Manager networks
• XP provides the Microsoft Interface Definition Language to describe
the remote procedure names, arguments, and results
Conf.dr.Carmen Timofte
Sisteme de operare
18
9
Domains
o NT uses the concept of a domain to manage global access rights within groups
o A domain is a group of machines running NT server that share a common security
policy and user database
o XP provides three models of setting up trust relationships
One way, A trusts B
Two way, transitive, A trusts B, B trusts C so A, B, C trust each other
Crosslink – allows authentication to bypass hierarchy to cut down on
authentication traffic
Name Resolution in TCP/IP Networks
o On an IP network, name resolution is the process of converting a computer name to an IP
address
e.g., www.bell-labs.com resolves to 135.104.1.14
o XP provides several methods of name resolution:
Windows Internet Name Service (WINS)
broadcast name resolution
domain name system (DNS)
a host file
an LMHOSTS file
o WINS consists of two or more WINS servers that maintain a dynamic database of name to IP
address bindings, and client software to query the servers
o WINS uses the Dynamic Host Configuration Protocol (DHCP), which automatically updates
address configurations in the WINS database, without user or administrator intervention
Conf.dr.Carmen Timofte
Sisteme de operare
19
All People Seem To Need Data Processing
Conf.dr.Carmen Timofte
Sisteme de operare
20
10
Modelul ISO/OSI
PDU
Protocol
DataUnits
-unitati
de date
ale
protocoa
lelor;
-relative
la nivel;
-alcatuite
din antet
+corp;
Conf.dr.Carmen Timofte
Sisteme de operare
21
Sisteme de operare
22
Modelul TCP/IP
Comparatie ISO/OSI, TCP/IP
Conf.dr.Carmen Timofte
11
Modelul ISO/OSI (*)
Nivelul fizic (Physical) realizează transmisia electrică a unui şir de biţi,
fără a se verifica corectitudinea acesteia. Nivelul fizic este în strânsă
legătură cu mediul fizic de transmisie a datelor. La acest nivel se
specifică: tipul de cablu, conectorul de legătură, rata de transfer, metoda
de codificare a datelor, metoda de acces la mediul de transmisie.
Nivelul legătură date (Data Link) asigură transmiterea corectă a datelor între două
sisteme între care există o legătură fizică. Secvenţa de date este împărţită în frameuri (cadre). Staţia receptoare face verificarea sumei de control asociată cadrului.
Nivelul reţea (Network) asigură dirijarea cadrelor prin reţea, stabilind calea de
transmisie a datelor de la sursă la destinaţie. Poate asigura multiplexarea mai
multor comunicatii pe aceeasi legatura de date.
1-3 inlantuite; 4-7 –cap-la-cap;
Nivelul transport (Transport) asigură transmisia corectă a datelor între staţia sursă
şi staţia destinaţie (de tip punct-la-punct), realizează secvenţierea mesajelor,
sincronizează ritmul de transmisie şi asigură retransmisia mesajelor pierdute sau
eronate.
Conf.dr.Carmen Timofte
Sisteme de operare
23
Modelul ISO/OSI (*)
Nivelul sesiune (Session) realizează conexiuni logice între procesele
constituente ale unei aplicaţii, asigurând dialogul direct între aceste
procese (initializarea, sincronizarea, terminarea dialogului).
Nivelul prezentare (Presentation) defineste semantica si sintaxa datelor
care se vor schimba. Se lucrează cu o reprezentare abstractă a datelor,
valabilă în toată reţeaua, asigurându-se conversia în formate specifice de
reprezentare la nivelul calculatoarelor, terminalelor etc. În unele aplicaţii
se asigură compresia datelor şi criptarea lor.
Nivelul aplicaţie (Application) asigură utilizatorului mijloacele necesare de
acces la mediul OSI. Se ocupa de semantica aplicatiei. Serviciile de bază
ale reţelei: poşta electronică - e-mail, transferul de fişiere, accesul la
distanţă.
Conf.dr.Carmen Timofte
Sisteme de operare
24
12