Modernization Hub

Chained List

Enhanced Definition

A chained list, also known as a linked list, is a fundamental data structure where elements are stored non-contiguously in memory. Each element, or node, contains both the actual data and a pointer (memory address) to the next element in the sequence, allowing for dynamic sizing and efficient insertions or deletions.

Key Characteristics

    • Dynamic Allocation: Nodes are typically allocated and deallocated dynamically at runtime using services like GETMAIN and FREEMAIN in z/OS, making them suitable for situations where the number of elements is unknown or varies.
    • Pointer-Based Navigation: Each node explicitly stores the memory address of the subsequent node, forming a chain. This is crucial in the address-space-oriented architecture of z/OS.
    • Non-Contiguous Storage: Unlike arrays, elements of a chained list do not need to occupy adjacent memory locations, which can be advantageous in fragmented memory environments.
    • Efficient Insertions and Deletions: Adding or removing an element only requires updating a few pointers, avoiding the costly data shifting operations associated with contiguous data structures.
    • Storage Overhead: Each node requires additional storage for the pointer(s) in addition to the data itself, which can be a consideration for very large lists.
    • Sequential Access: Accessing a specific element often requires traversing the list sequentially from the beginning (or a known anchor point), which can be slower than direct indexing in arrays.

Use Cases

    • Operating System Internals: z/OS and its components extensively use chained lists for managing system resources, such as Task Control Blocks (TCBs), Request Blocks (RBs), storage queues, and I/O request queues.
    • Application Data Management: COBOL, PL/I, and Assembler programs often employ chained lists to manage dynamic sets of records, buffers, or transaction queues where the number of items changes frequently.
    • CICS Resource Management: CICS regions utilize complex networks of chained control blocks to manage tasks, programs, files, and other resources, linking them together for efficient access and state tracking.
    • Spooling Systems: Managing print queues or job queues where jobs are added, processed, and removed dynamically, often implemented as chained lists.
    • Custom Memory Pools: Implementing application-specific memory allocators or buffer pools where free blocks are linked together for reuse.

Related Concepts

Chained lists are a core data structure often implemented using pointers or addresses in low-level languages like Assembler and high-level languages like PL/I. They are a common alternative to arrays when dynamic sizing and efficient element manipulation are more critical than direct random access. Many control blocks within z/OS, such as TCBs, ASCBs, and DCBs, are interconnected via chained lists, forming the intricate web that defines the operating system's state and resource allocation. They are fundamental to how SVCs and system services manage resources.

Best Practices:
  • Robust Pointer Handling: Always validate pointers (e.g., check for NULL or invalid addresses) before dereferencing them to prevent 0C4 abends or storage violations.
  • Careful Memory Management: Ensure that every GETMAIN operation has a corresponding FREEMAIN to prevent storage leaks, especially in long-running batch jobs or CICS regions.
  • Concurrency Control: In multi-tasking environments (e.g., CICS, parallel batch), use appropriate serialization mechanisms like ENQ/DEQ or SERVES when modifying shared chained lists to prevent data corruption.
  • Clear Node Structure: Define a consistent and well-documented structure for list nodes, including data fields and pointer fields, to enhance code readability and maintainability.
  • Performance Awareness: While flexible, chained lists can be slower for random access than arrays. Consider the access patterns and potential performance implications for very large lists.

Related Vendors

Trax Softworks

3 products

Related Categories