Monday, October 27, 2025

Windows Program Set Up

WinMain is the main program in Windows.  Windows passed in 4 parameter when WinMain starts - Instance handle (type HINSTANCE), Previous instance handle (HINSTANCE), a pointer to the command line string (LPTSTR) and the options for the window to be created (INT).

the first step is to register the window calling RegisterClassEx with a WINCLASSEX structure. The structure contains parameter about the main window to be created like if it is to be redrawn when the window is resized horizontally or vertically, the program instance, pointer to the window's call back function, pointer to the icon and mouse etc.  The system call returns an integer - 0 if error and non-zero if ok. 

The WinMain calls CreateWindow function to create the first window.  It passes information about the window to be created like the title string, window style (e.g. overlapping), size and the application instance handle.  CreateWindow returns a handle to a HWD structure.

At this point, the window is still not visible, WinMain calls ShowWindow and UpdateWindow, passing the HWND handle to draws the window.

This complete the initialization.  WinMain then goes into a message loop to listen for messages to process. It calls GetMessage which will block the program until a message come in.  It then call TranslateMessage and DispatchMassage which passes the message to the call back function to process.


Sunday, October 26, 2025

PCI

PCI was a parallel bus of 16 bit wide. PCI express change to use serial bus design. The protocol insert additional bits to achieve error for data inyegrity thus the data rate is less than the transfer capability.  The effective data rate improves from generation to generation by varying the amii pi unit of these overhead bits  

PCIe support full rate transfer bidirectionally. The standard support multi-lanes transfer from 1x to 32x. 

Saturday, October 25, 2025

Winmain

This is the main routine in a windows program. It receives parameters from Windows include the instance handle that representing the current task, parameter passed to the program. If the program is already running, the usual treatment is for the program to terminate and this no new instance will run parallel to the existing instance. 

Saturday, October 18, 2025

Serial data bus

Each bus consists of 2 lines to allow differential signalling that resist interference. 

Connections between the processor and the io chipset consists of several serial data buses called hsio (high speed io lanes). Each lanes may be dedicated to a specific device such as pcie, usb and sata etc. 

Parallel data bus

It uses multiple line for transfer. The limitation is a cap on the speed as satay propagation delay in each data line may differ. 

Another disadvantage is it can only operate in one direction at a time (half duplex). One needs another set of cable to achieve full duplex. 

GDDR

GDDR has wider data bus for throughput. SDDR on the other hand emphasizea latency. 

DDR

Double data rate DRAM means data transfer rate is doubled to the earliest RAM. The transfer happens at clock edges

Synchronous DRAM refers that the DRAM chip is synchronised zed with the memory controller through a shared clock

To increase transfer throughput, DDR4 device the memory into banks and grouping banks.  Transfer can be done simultaneously with multiple banks. 

Some systems implement multiple io controller that owns a set of bank to further increase throughput. Each controller is a channel. OS must be smart enough to layout the memory crosses the topology to maximize throughput. If all data is place in one bank, throughput is still serial. .