Wednesday, December 27, 2023

CICS Relinquish Control

 Where there is no task to execute, CICS will issue an OS wait to let lower priority jobs to tun. The ICV setting control the max time CICS will wait. An ICV ECB will created in the list of I/O ECB that CiCS waits on. 

CICS CSA

 In MVS, Common System Area is located at the top of the region. It is pointed to by R13. The first part of CSA is the register save area which is common for OS to point to via R13. CSA contains anchor pointer for many control blocks. CICS tables have been moved out to the OFL area. 

CWA followed CSA is not in used by CiCS functions. It is a global memory area that can see by all user transaction. There is no pointer in CSA to point to CWA. This CWA is located by a fixed offset from CSA start address. 

Optional Feature List follows CWA and is an extension to CSA. Because CWA is not pointed by CSA. Thus CWA cannot be relocated to another address and be located easily to give more space to extend CSA. OFL is added after CWA as an extension of CSA

80286 Protected Mode

 80286 has 5 system registers used to support protected mode.  When 80286 starts up, it is in real mode.  Real mode uses 24bit real address.  When in real mode, 80286 acts like 8086 but with higher throughput.  To enter protected mode, system program goes through 5 steps:

(1) Set up Global Descriptor in the real memory and load its address to GDTR. GDTR map the system pages that are shared by all processes

(2) Load the interrupt service routines in real memory and load its address to IDTR

(3) Set the PE bit in MSW (machine status word) to activate protected mode.  There is no way to go from protected mode back to real mode except by a hardware reset to 80286

80286 now acts in protected mode.  In other words, it will start translating virtual address and automatically switch tasks.   To complete the sequence, the system needs to load the task register and LDTR.


CICS Runaway Task

 A timer interrupt is set to detect task running in a loop and does not relinquish control based on the ICVR value. When the timer interrupt spring, it check the current running exceeded the time setting. If it does, the PSW will be set to x0000 to force a program check. DFHSRP intercept the check and change the abend code to ACIA. 

Friday, December 22, 2023

Program Compression

 CICS program subpool is separated from other subpool and is allocated from top down. Program compression means non-resident programs which are not in use is deleted during SOS.  The PPT is scanned to identified such program which may be reloaded in the war future. So program compression is a resource intensive operation. 

SCP maintained a minimum address for program subpool to keep the other data subpools from invading the program storage.  Program storage allocated below the threshold are freed as soon as the program use count is zero. 

CICS GETMAIN SOS

GETMAIN is issued by user program or by CICS routines on behalf of the user task.  Storage will be allocated from existing subpool page if available, or a new page if there is free page in DSA. When storage becomes a not available to satisfy a GETMAIN request, the task will be suspended with a DCI value set. The system enters a SOS condition and program compression is activated to try to release storage. 

CICS will then retry the GETMAIN from the suspended tasks and if successful, CICS will turn off the SOS condition. Otherwise, the SOS will continue.  This action also happened when a FREEMAIN happens during SOS. 

Task Storage

 TCA is created in the task subpool when a task was attached. The storage acquired by a task is chained from TCA SAA with the most recently acquired storage at the front of the chain. The next allocation is found in the SAA. The last area points to the STCA. 

TIOA is chained off from TCTTE instead of TCA because there is a chance that the task has gone when its terminal message still waiting to be sent. 

Free Area Queue Element

 FAQE is used to chain up free space within pages of same subpool. It is allocated after the storage area requested.  The element is linked by a double linked list  

Adjacent free areas will be consolidate upon RELEASE. If the FAQE unit s corrupted by user program, this type of storage violate can be detected earlier than using SAA. When it t happens, a dummy FAQE is created. 

PAM byte maps

 The byte map is used to indicate if the corresponding DSA page was in use or not. If in used, which subpool owns the page. 

There is a second byte map used to record some extended information for some of the subpools. 

CICS Subpools

 Control subpool is used to keep CICS control blocks such as DCA. The allocation is typically small and use a first fit algorithm. It uses 4 bytes SAA. 

Teleprocessing subpool contains TIOA. This subpool is usually large when there is a big network. The pool uses 8 bytes SAA and with end SAA to detect storage violation. 

Task subpools is used to hold control structures related to task such as TCA and VSWA. Program’s working. Storage and linkage section storage are also allocated out of this subpool. The storage requested by program at different time is not contiguous. The storage chain is addressed from TCA. As the storage is under control of user programs, CICS uses 8 bytes SAA and duplicate SAA at end of the area 

Shard subpool contains TS main storage and BMS. Four bytes SAA s used and no duplicate SAA

CICS SAA

 Storage accounting area has 2 formats - 4 bytes or 8 bytes. Some subpool has a duplicated saa ar the end of the storage area.  The saa at end of the storage is used to detect storage violation when the task write beyond the requested area. The saa contain a byte value that is stored see to initialize the storage. 

The 8 byte format contain extra field that chain up the next area belongs to the same task  subpool under the control of CICS (less susceptible to storage violation)uses 4 byte saa

CICS PAM

 Page allocation map describes the current DSA usage. Each PAM subpool entry is 16 bytes long describing each subpool.  It records the subpool ID and the number of pages assigned in the subpool. It also contain the FAQE pointers which chain up the free area ms within the pages which can be used for future requests. Program subpool does jot uses FAQE because the basic allocation for program is on page. Task storage also does not use FAQE. He pointers are kept in TCA instead. 

PAM also contains other fields like page size of DSA, the cushion size, the address of the first DSA page etc. 

the address shifting factor field contain a value depending on the page size (2K or 4K) and is used with the starting virtual address of DSA to conveniently deride the DsA page number for an arbitrary address or to locate the starting address of an arbitrary DSA page 

CICS DSA

 DSA constitute the memory area left over after all the program, buffer, tables, control blocks are allocated. DSA is divided into pages. Each pages are assigned to a different CICS subpools. Subspool determines how the storage is allocated to requests made. 

Examples of subpools are for control, telecom, task, RPL and program etc. program subpool pages are allocated from the top of DSA. Programs generally uses more space per request. The other subpools uses relatively smaller chunk of space 

CICS SCP

 Storage Control Program managed the DSA allocation. SCP issues GETMAIN and FREEMAIN macro to obtain and release memory for DSA. It monitor the usage so that it can issue warning (based on the storage cushion value) and perform recovery is storage is depleted.  Requests are queued when this happens. 

Monday, December 18, 2023

CICS TCA

The system TCA contains information used by the CICS control programs. It contains anchor points for task storage acquired by the transaction. It also contain pointer to COBOL working storage (TGT). 


The user TCA has s used to communicate information of request to CICS. It contains space for register save for KCP, SCP and for calling temp storage, file control and transient storage module  

Friday, June 2, 2023

Scaled Numeric Representation

 Scaled numeric upscale a the fractional part to whole number by multiplying its base. For example for base 10, the value of 2.4 is scaled up to 240 by multiplying with 100. Once the number is scaled up, it can be involved in calculation like a normal binary number. The result will then scaled back accordingly.  

Fixed point real number

Fixed point means the decimal point is fixed at a certain bit position.  For examples, one can use 8 bits for the number and another 8 bits for the fraction.  The number point is interpreted as the usual binary representation, signed or unsigned.  Each bit in the fraction part is interpreted based on its bit position.  The value at position n (counted from left to right) = 1/(2^n) or 2^-n

For example if the fraction = 10011111,

1/(2^1) = 1/2 = 0.5

0/(2^2) = 0/4 = 0

0/(2^3) = 0/8 = 0

1/(2^4) = 1/16 = 0.0625

1/(2^5) = 1/32 = 0.03125

1/(2^6) = 1/64 = 0.015625

1/(2^7) = 1/128 = 0.0078125

1/(2^8) = 1/256 = 0.00390625

The decimal value is = 0.5 + 0 + 0 + 0.0625 + 0.03125 + 0.015625 + 0.0078125 + 0.00390625 = 

Fixed point is popular in the past when floating point unit is not available.  Even with FPU become a standard hardware component equipped in all modern processor, fixed point is still used in game because it is still more efficient than floating point calculation   

Comparing to using BCD (binary coded decimal), fixed point has higher resolution  for example 8bits can be used to represent BCD values from .00 to .99  8 bus in fixed point representation can represent 2^n fraction value  

Fixed point still cannot be used to represent all real number and only an approximation (eg 1/3).


Tuesday, May 2, 2023

Bootsect

Bootsect (bootsect.s) is 1 sector in length and loaded to memory location x07C00 (31,744B) by BIOS interrupt 13.  Bootsect runs in real mode which addresses 1MB (20 bit address. 1MB = 1,048,576B).  BIOS IVT is loaded in x00000 to x003FF by BIOS (256 interrupts with 4 bytes each total 1KB), followed by BIOS data (256B from x00400 to x004FF).  The interrupt service routine is 8KB in length and is loaded to x0E05B, which is 56KB after.  So the memory is not used from about 65KB and up to where BIOS is located at xFE000 for 8KB until the end of the real memory.

Once Bootsect is loaded and starts to run, it will load the next 2 sectors from the boot device into memory.  The 2 sectors contain the set up program (setup.s).

Before reading in setup.s, Bootsect firstly relocates itself from x07C00 (BOOTSEG at address ~32K) to x09000 (INITSEG at address 576K).  Bootsect the establishes the stack at x9FF00 (address ~655K) with ~63KB space from end of INITSEG.  

Bootsect uses interrupt x13h (disk service program) to load setup program to memory at address x90200 (512KB = 1 sector after bootsect.s) for 5 sectors (2.5KB or A00).  

Bootsect then loads the system modules into memory.  Bootsect uses interrupt x13h again and loads 240 sectors (120KB) into x10000 (address at 65K, after the BIOS IVT, BIOS data and IVT service routine).  As this takes some time to load so many sectors from floppy disk, Bootsect will display "Loading System...." message on the console.  System modules span from x10000 to x11E00 (up to address ~73K).

Lastly, bootsect inspects the root device number and record in at 01A964 (root_dev) in system data.  Bootsect than transfers the execution to the set up program at x90200.

Sunday, April 9, 2023

From BIOS to Bootsect

When one powers on a PC  with am Intel microprocessor, the core starts up in real address mode.  Real mode has a 20-bit address space (x00000 to xFFFFF) which is 1MB long.  The core initializes the code segment (cs) register to xFFFF and the IP to x0000.  This makes the core to start executing the memory location xFFFF0 which is a location in the BIOS.

BIOS first set up the interrupt vector table (IVT) in the first 1KB of memory (x00000 to x003FF).  The BIOS data, which is 256B long, is placed next and after the IVT (from x00400 to x004FF).  The interrupt service routine is placed between x0E05B to x0FFFE (near the 56KB mark from start of memory).  The IVT is essential for BIOS to load the boot sector into memory.

IVT has 256 entries of 4-bytes each.  Two bytes for the segment register value and 2 bytes for the offset.

BIOS invokes INT 19h using IVT.  INT 19h load disk 0, track 0 and sector 1 into x07C00 (about 31KB from start of memory).  The sector is 512B long and is called Bootsect.


Notes on C 2

 FIFO is byte-oriented.  One reads and writes based on number of bytes.  Message queue has a concept of message with a type attribute.  One can retrieve message based on type which could be out of arrival order.

Shared memory needs to have a backing file.


Sunday, March 12, 2023

Notes on C

 Function is a callable block in assembly.  It means the block is marked with a label at the beginning so it can be jumped to symbolically.

Function defined with implementation details placed before (function) main served double up as a function declaration (signature that other function can call accordingly).

The main function is called by one of the exec family call and value is return to exec call when the C program ends.

Command line can be passed to the main function as argument.  The argument are passed as an array of string.  It can be declared as char *argv[] or char **argv.

There is no boolean type in C.  Integer (int) is used to represent false with a value of 0.  1 or any positive value represent true.  While (1) represent an infinity loop with a always true condition.

Condition used in control statement (for, while, do, switch etc) must be enclosed by parenthesis.

For SWITCH statement, execution will start from a matching case statement and continue from there straight until it reach a BREAK or end of SWITCH.  In other words, it will also execute codes in ensuing cases that following the matching case.

Array variable is a type of pointer.  It points to the first item of an array.  So is a function name.  It can be passed as a pointer as an argument to another function.

Pointer arithmetic convert an offset to its product with the item size.  For example, arr+3 = arr+(3*4) for an array of integer.  The compiler will perform the offset arithmetic on behalf of human.

There are 4 storage classes.  extern and static are for both function and variable.  auto and register are applicable to variable only.  

Variable is defined when it is assigned a value.  Variable is declared when no value is assigned.  There can only be 1 definition statement for variable in a program but there could be many declaration.

int a = 10; /*definition*/

int a; /*declaration*/

Variable defined outside a block is either static or extern (default).

Variable defined within a block is either register or auto (default).

When a variable is defined as extern or static, it exists through out the program's life time.  

A static variable declared in a function (block scope) is initialized once even the function may be called repeatedly.  A static variable has default value 0 if it is not initialized.

A static variable declared outside a function (outside a block) has scope from the point of declaration to the end of the file containing the declaration code.  It is not visible outside the file (i.e. in other program files that may be compiled together).

A extern variable has global scope if it is defined (initialized) in one file and is declared in other files that require access to the variable (and that are to be compiled together).

register class is typically not required anymore as compiler would optimize the code by assigning variables to register for efficiency.  If compiler deems no register is available, variable defined as register will be treated as auto.

volatile is not a storage class.  When variable is defined as volatile, the programmer informed the compiler to avoid optimize it by assigning it to register.  For example, if a variable is to be updated by ISR (e.g. placement for received byte), the variable needs to be in memory rather than register.

Function can be defined as static or extern, but not auto or register.  A static function is visible within the file containing the function.  It is similar to private function in C++,  A extern function is visible outside the file it is defined when the other file declares the function.



Saturday, February 25, 2023

java class in a class

A class defined in another class is called a nested class when it has the static keyword and inner class if it does not has the static keyword. A inner class does not has a reference to its outer class but an inner class has. In other words, a inner class can access the outer class instance variable