2000 os2 architecture - a programmer's overview - scott garfinkle

Post on 21-Aug-2015

125 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

OS/2 ArchitectureA Programmer's Overview

Scott E. Garfinkle(C) IBM Corp. 2000

Protection

Ring protection - lower number => higher privilege level

Ring 0: Kernel, Device Drivers, FilesystemsRing 1: Not usedRing 2: "IOPL" -- mostly print and videoRing 3: Everything else

I/O Adressing requires Ring 2 or VDMProcesses have their own virtual address space (except for explicitly shared memory)

Memory Management

Physical Memory is the amount of RAMVirtual Memory is RAM+free disk space on drive where swapper.dat is located.Memory is managed by 4k pages.

name swapper.dat left over from selector swapping in OS/2 1.xswapper.dat is now the "paging file.

Memory Management (continued)

Everything fits in a linear (4gb) selectorNon-linear selectors are used for compatibility with 16 bit codeYou can map back and forth using "thunking". laddr == ((sel & ~7) << 13)This doesn't work for "packed" code. You CAN'T thunk addresses > 0x1fffffff. This gives us the 512mb "compatibility region."

Ring 0 Entities

OS2KRNL and OS2LDROS2KRNL provides all basic OS services, including tasking, memory management, etc.OS2LDR provides most hardware-specific function, excluding memory management

Platform-Specific Drivers (PSDs) are drivers to provide SMP support on a bus-specific basis. Virtually all systems use the Intel APIC bus now, which is OS2APIC.PSD.

Ring 0 Entities (continued)

Installable File Systems (IFSes) provide access to files not on a local FAT drive

HPFS, HPFS386HPOFSCDFSUDFJFS (note the new /SPARSE flag)netwksta.200 (IBM Lan Requester)nwifs.ifs (Netware)

Ring 0 Entities (continued)

Installable Security Systems (ISSes) work in conjunction with OS/2 Security Enabling Services (SES) to provide local security at approximately the C2 level. Only two at a time can exist: One for most of the services and one for antivirus. See Holger Veit's web page

http://set.gmd.de/~veit/os2/index.html

Ring 0 Entities (continued)

Device Drivers provide any miscellaneous services that have to exist at ring 0. DDs are really just DLLs with a special header

BASEDEV= is for device drivers that need to get loaded first (in order: .SYS, .VSD, .TSD, .ADD, .I13, .FLT, .DMD).DEVICE

Block DevicesCharacter DevicesVirtual Devices (for VDM support)

Processes

Processes are a way to collect, identify, and manage ownership of a bunch of resources.

Threads are the basic unit of execution. A thread executes code. It "owns" nothing but a stack and a little thread local memory.Memory objects are allocated either explicitly or from a link object and are either private or shared.

Processes (continued)

File handles are ways of getting to the filesystem (FAT, IFSs, DDs). These are the ONLY objects inherited by child processes.Semaphores: both 16 and 32 bit sems are available to both 16 and 32 bit code.A process MUST have at least thread one. Other threads can come and go.

It's threads that are scheduled, not processes!

Processes (continued)

Sessions - simulate the idea of a separate virtual computer. Each session ("screen group") has its own interface to the mouse (MOU) , keyboard (KBD), and screen (VIO).

"Detached" sessions have no MOU/KBD/VIOAll PM sessions share a screen grouprelatively low max SG countMOU/KBD/VIO code is 16 bit only (use thunks).

Processes (continued)

All objects (files, memory, etc.) are automatically cleaned up by OS/2 at process termination time. Shared memory objects persist until there are zero client processes.

Files

A process gains access to a file handle when a thread uses DosOpen (etc.) or because it inherited the handle (e.g. stdin).Handles can refer to objects mediated by an IFS (files, dirs), a volume (e.g. A:), a named or unnamed pipe, or a device (e.g. con$).A handle is an index into a process' JFN tab.

Files (continued)

Each JFN entry is an SFN, which is an index into the SFT. Each reference to a file has an SFT (which might be shared due to inheritance).

Each file-type SFT points to an MFT.Each SFT is flagged with some info, e.g. whether 64 bit access is allowed, the type of file, etc.Other info includes whether local or remote, busy, and file or device type.

Files (continued)

Each unique file open on the system has an MFT entry

An MFT points to its chain of SFTs. An MFT points to a chain of file locksAn MFT identifies the relevant filesys volume

Each drive on the system has a volume parameter block (VPB) which gives info on the IFS, if any, unit # (i.e. drive letter), etc.

Semaphores

16 bit semaphores: RAMSEM (unmanaged by the system)FS RAMSEMSYSSEM (256 max per system).

32 bit Sems - Mutex, Muxwait, Event. Total 64k shared for system, 64k private per proc, 256 Muxwait (16+32 bit) for system. Shared sems can be named or unnamed. Mutex Semaphore

Semaphores (continued)

Event Semaphores - can do PostOne AutoResetMuxwait Sempahores - max 64 sems in list

Interfaces

Memory - Private,Shared,Instance,High,Low

Low memory (from 0-512mb): Can be thunkedHigh memory (from 512mb-1gb or, if set, VIRTUALADDRESSLIMIT):

requires FP13+, WSeB, or WS SMP.supports allocating memory above 512mb with OBJ_ANY (0x400) flag.is allocated out of the compatibility region if possible, but not necessarily.can NOT be used for 16 bit code

Interfaces (continued)

Private/shared/instance memoryprivate allocations affect only the current process (unless it changes the private/shared boundary)shared allocations are potentially available to all processes, but access must be given to or gotten by each accessing processInstance allocations are private memory objects allocated by DLLs

Interfaces (continued)

Exception Management16 bit interfaces are per process

signals (ctrl-break/ctrl-c is per screen group)harderror (popup) suppression for filesys

32 bit interface is like try/catch/throw in C++

Each thread is independentXCPT_SIGNAL is sent to thread 1Asynchronous exceptions can be held with DosEnterMustCompleteHandlers MUST be registered on the stack

Traps

Ring 3 trapsBy default, cause SYSxxx messages Can be suppressed/logged/dumpedCan be ignored by an application

Ring 0 traps -- "trap 000x" black screenCan be dumpedIPE (no registers), "Exception in Device"Not logged in popuplog.os2

In Conclusion

More detailed info exists in the "OS/2 Debugging Handbook"

Ask questions in the internet newsgroups:comp.os.os2.bugscomp.os.os2.misccomp.os.os2.programmer.miscetc.

top related