Usually you might have faced the following issue while compiling on Visual Studio .NET 2005.Read more on MSDN
error LNK2019: unresolved external symbol __chkstk referenced in function...
This is caused by stack probes. Either you can increase the size of the stack to what ever maximum your function uses using Gs option (Default for x64 is /Gs8192) or using heap.
Gs option is an advanced feature to control stack probes. A stack probe is a sequence of code the compiler inserts into every function call.
Introduction
The Advanced Configuration and Power Interface (ACPI) is an open industry standard developed by HP, Intel, Microsoft, Phoenix, and Toshiba) defines common interfaces for hardware recognition, motherboard and device configuration and power management.
ACPI Power Management States
- Global system states
- Sleeping states
- Device Power states
- CPU Power states
- CPU / Device Performance states
- CPU Thermal Monitor states
- Global system states apply to the entire system and it is user-visible.
- Divided into 4 states – G0, G1, G2, G3
G0 Working State
- This is the power state where computer is able to run applications.
- Power consumption is the highest among all G states.
G1 Sleeping State
- The computer appears "turned off" to the user.
- Most of the system context will be saved in memory - either RAM or the hard drive.
- Example : Switching the computer into "Standby" or "Hibernate" mode in Windows XP.
G2 Soft Off
- The whole is system is turned off, with the exception of the main switch of the power supply unit.
- Some debug and machine check registers still retain their error codes, if there are any.
- Power consumption is almost zero.
- The operating system needs a reboot, and the wake up latency is long.
- Example : Choose "Shut Down Computer" in Windows XP, but the main power switch is not turned off.
The computer is completely turned off by cutting the main power into power supply unit.
Power consumption is zero.
G Power Consumption
G0 > G1 > G2 > G3
Sleeping States (S-States)
- Sleeping states define the computer's ‘sleeping methods’ in the G1 (sleeping) state. In all the sleeping states (except S0 and S5),
- Divided into 5 states – S1, S2, S3, S4, S5
- The CPU executes no instructions. It is having a good sleep!
- User applications will not run (duh… the CPU is sleeping!)
- When the system is ‘awakened’, it will continue working from the point before it slept.
S0 State
- Same as G0
S1 State
- The hardware maintains all its system context.
- The CPU input clock will be stopped, and its caches will be invalidated.
- The system memory goes into its self-refreshing mode.
- All system clocks are turned off, except the real time clock.
- Wake up latency is low. It takes about 2 seconds to go back to the G0 working state. The hardware will be responsible for restarting the system clocks.
- Example : “Stand-by” mode in Windows XP, if the S3 state isn’t supported.
S2 State
- The CPU and its caches are powered down, instead of just gating the clock input and invalidating the caches.
S3 State
- The S3 state powers down the CPU, cache, chipset and peripherals, except RAM.
- RAM goes into a low-power, self-refreshing mode.
- The wake-up latency is about 5-6 seconds.
- Example : "Stand-by" mode in Windows XP if the S3 state is supported by hardware.
S4 State
- All devices including system RAM are powered down.
- Only platform settings are maintained, while other settings are stored in a special partition in the hard drive.
- The power consumption is very low (< 3W), as almost everything has turned off.
- We need to go through the BIOS boot sequence again when the computer is awakened.
- The OS reboot is not required. It will automatically return to where you last left it.
- Example : "Hibernate" mode in Windows XP
S5 State
- Same as G2
S Power Consumption
- S0(G0) > S1 > S2 > S3 > S4 > S5(G2)
Device States (D-States)
- Device states occur in the global system G0 working state.
- Defined to enable device vendors to design ACPI-compliant products, so that operating system that support ACPI, like Windows XP, can manage the devices.
- Divided into 4 states – D0, D1, D2, and D3.
D0 State
- In this state, the device is operating at its full power.
- Example : A HDD in active use.
D1 State
- The device can choose to discard its context.
- However, the bus connected to this device should not do anything to cause the context loss in the device.
- Power consumption is lower than the D0 state, as some working units in the device will shut down.
- Example : After idling for some time, the laser in the DVD-ROM drive will automatically turn off, but the drive controller will still be active.
D2 State
- It is similar to D1, but the bus is free to some power management, like lower the current and voltage.
D3 State
- The device in this state can be completely turned off.
- Maximum power saving is achieved.
CPU Power States (C-States)
- CPU (Sleep state)C-states occur in the global system G0 state.
- Divided into 7 states – C0, C1, C2, C3, C4, C5 and C6.
C0 State (Active)
- This is the CPU's maximum working state, where it is actively accepting instructions and processing data.
- Power saving is virtually zero.
C1 State (Halt)
- It is simply done by executing the assembly instruction “HLT” (Halt).
- This will stop the instruction pipeline within the CPU from executing any instructions.
- Wake-up time is ultra fast (only about 10 nano seconds).
- The CPU is able to save up to 70% of its maximum power consumption.
- All modern processors must support this power state.
C2 State (Stop Grant)
- The processor core clock and platform I/O buffers are gated.
- The transition time from C2 to C0 is 10 times more (~100 nano seconds).
C3 State (Deep Sleep)
- The bus clock and PLLs are gated.
- In a multi-processor system, the processors no longer handle FSB snoops to maintain cache coherency. Cache contents are invalidated.
- In a single-processor system, memory transactions are prohibited but cache contents are not invalidated.
- CPU still saves around 70% power, but the platform power will be reduced even more than C2.
- Wake up time is 500 times longer than C2 (about 50 micro seconds).
C4 State (Deeper Sleep)
- It is similar to the C3 state, but with two main differences.
- First, the core voltage is reduced to a very low level (less than 1.0V) to decrease current leakage.
- Second, data stored in the L2 cache will be reduced bit by bit over time.
- The CPU can save around 98% of its maximum power.
C5 State
- When the data in the L2 cache is reduced to zero.
- Wake-up time is more than 200 micro seconds.
C6 State
- New power management feature in Penryn.
- When the L2 cache contents are shrunk to zero, the CPU will go into an even lower core voltage.
- CPU context is no longer preserved.
- Power consumption is virtually near zero.
- In a multi-core processor, there can be multiple C-states in each core, but only one processor C-state is enabled at one time.
- The processor C-state is equal to the highest C-state of any processing core.
- Cx = max (Cx1, Cx2, Cx3, …… , CCxn)
CPU / Device Performance States (P-States)
- P-states define the power management state while the CPU / device is within its executing state, C0 for CPU and D0 for device.
- Usually clock speed and voltage varies depend on workload.
- The amount of P-state is CPU / Device specific
- P0 : Minimum p-state, highest power consumption.
- P1, P2, P3…. : P1 > P2 > P3 and so on, in terms of power consumption.
- Pn : Maximum p-state with the lowest power consumption.
- P-state power management can be seen in modern CPUs and GPUs.
- It allows them to control their active power according to the load at any particular moment.
- The number of P-states is implementation-specific.
- Wake-up time is slower, but still much lower than 1 second (~160 micro seconds).
CPU Thermal Monitor
- The main purpose of the thermal monitor is to decrease the processor power consumption when it is running too hot.
Thermal Monitor 1
(TM1)
- When the thermal treshold is exceeded, TM1 changes the clock duty cycle to lower down the CPU power consumption. Users will feel choppiness in their applications when TM1 is applied.
- The throttling can be done on a per-core basis (only CPU TM1). This means Core 1 may do TM1 but Core 2 can still run normally.
Thermal Monitor 2
(TM2)
- When the thermal treshold is exceeded, TM2 changes the clock speed and core voltage to reduce the CPU power consumption. All cores will activate TM2 simultaneously as there is no per-core support. Users will not feel the choppiness as the transition between P-states are very smooth. TM2 is only supported by the CPU.
Extended Thermal Monitor
(ETTM)
- When the thermal condition is very bad, TM1 is activated on top of TM2 to aggressively reduce the CPU power consumption.
"DMA (also referred to as bus mastering) is a technique that some components and devices use to transfer data directly to and from memory without passing through the Central Processing Unit (CPU). DMA reduces CPU overhead by providing a mechanism for data transfers that do not require monitoring by the CPU." (description by Microsoft Corporation)
Understanding Device Names and Symbolic Links
10:15 AM | DeviceNames, Symbolic Link, Windows Internals with 0 comments »Introduction
Today while having Lunch with my colleagues we had a discussion over symbolic file names in windows. My argument was it was a persistent file and so it should be a physical file system. But my friends argument was it cannot be a physical file since it cannot be opened, closed like a normal file in the file system. So this encouraged me to go into a little depth to understand what a symbolic link in windows.
In windows there are two types of device names, Windows NT device names and MS-DOS device name. These names are located in the Windows NT Object Manager's namespace. The Windows NT kernel and the kernel mode drivers use the NT device name and the Win32 programs use the MS-DOS device names and is a symbolic link to NT device name.
NT Device names
When a kernel mode driver is loaded, its initialization outine registers a device name with Windows NT Object Manager. (Use WinObj.exe from sysinternals to view all NT Device names in your system). These names have the format \Device\CDRom0, etc and can be found in the \device drirectory of Object Manager's namespace.
Win32 programs access these device names using the MS-DOS device names such as A:, C:.
MS DOS Device names
These device name exists in Object Managers \?? directory. Multiple MS-DOS Device names can point to a single NT device name.
Symbolic Links
Symbolic links created by system persist across computer restarts because they are stored in registry. These are the links created between MS-DOS device name and an NT device name.
Wait and watch for Vista...you will find these symbolic links are physical files.
API
QueryDosDevice - used to know the NT device name associated with MS-DOS device name.
DefineDosDevice - used to manipulate a symbolic link. Create a new or remove.
Articles