Original practice scenario: A hypothetical compiler-toolchain build has modules with prerequisites and several parallel workers. Design a scheduler that detects cycles and produces explainable failures.
Read model answer +
Represent the build as a dependency graph with immutable task inputs. Parallel execution is safe only when prerequisites are satisfied and task results can be identified and reused correctly.
Work through it
Validate task identities and dependency references, compute indegrees and enqueue ready tasks; if no progress is possible while tasks remain, report a cycle or blocked dependency.
Dispatch ready work within resource limits, decrement dependent counts only after successful completion, and retain failure causes for tasks that cannot start.
Key cached outputs by toolchain, configuration and input fingerprints, testing disconnected components, repeated dependencies and deterministic output collection.
Tradeoffs to discuss
Maximal parallelism reduces elapsed time but can exhaust memory or disk bandwidth; resource-aware scheduling may deliberately leave workers idle.
Common pitfalls
Do not classify every blocked task as independently failed when one prerequisite caused the blockage.
A cache hit is valid only for the declared inputs, not merely the same module name.
Original practice scenario: A hypothetical processor-support library reads a packed capability record produced by several device generations. How would you parse it safely and preserve forward compatibility?
Read model answer +
Specify byte order, record length and version semantics before decoding flags. A bit position has meaning only within its documented layout, and unknown values need an explicit handling policy.
Work through it
Validate the minimum envelope and declared length before reading offsets, then decode fixed-width values using the specified endianness rather than host-native assumptions.
Separate recognized capabilities from reserved or unknown bits, checking dependent features and returning a structured unsupported-version result when interpretation is unsafe.
Use fixtures with boundary lengths, mixed flags, extra trailing fields and malformed records, preserving raw diagnostic identifiers without claiming unsupported hardware works.
Tradeoffs to discuss
Ignoring documented optional extensions aids forward compatibility; accepting an unknown incompatible layout can produce incorrect capability decisions.
Common pitfalls
Do not shift signed integers without considering sign extension and width.
A decoded feature flag is not a substitute for checking operating-system and runtime support before enabling the feature.