Task Manager
Overview
The Task Manager provides comprehensive process and system monitoring for FreeWorld OS. It features dual CPU metrics inspired by aircraft instrumentation, showing both traditional CPU usage percentage and CPU pressure (how hard the CPU is working relative to its current clock speed).
Dual CPU Metrics
The Task Manager displays two complementary CPU metrics:
1. CPU Usage % (Traditional)
Standard CPU usage percentage showing how much of the CPU's time is being used.
- 0-100% range
- Shows percentage of CPU time in use
- Familiar metric from traditional task managers
2. CPU Pressure (Innovative)
CPU pressure shows how hard the CPU is working relative to its current capacity. This is calculated as:
Pressure = (Usage % × Max Clock Speed) / Current Clock Speed
This metric is particularly useful for:
- Laptops: Distinguishing between low power mode and actual computational load
- Throttling Detection: Identifying when CPU is throttled (pressure > 100%)
- Power Management: Understanding if high clock speed is needed or wasteful
Example Scenarios
| Scenario | Usage % | Clock Speed | Pressure | Interpretation |
|---|---|---|---|---|
| Normal operation | 50% | 3000 MHz (100%) | 50% | CPU working normally at full capacity |
| Power saving mode | 50% | 900 MHz (30%) | 166% | CPU is working harder than its current capacity (throttled) |
| Thermal throttling | 100% | 1500 MHz (50%) | 200% | CPU overloaded and throttled due to heat |
| Inefficient | 20% | 3000 MHz (100%) | 20% | Low usage but high clock - consider power saving |
Features
- Dual CPU Gauges: Usage % and Pressure metrics
- Clock Speed Monitoring: Current, min, and max clock speeds
- Memory Metrics: Total, used, free, cached, buffers
- Process List: All running processes with CPU and memory usage
- Network Metrics: Bytes sent/received, packets (future)
- Load Average: 1-minute, 5-minute, 15-minute load averages
- Real-time Updates: Updates every second
- Status Interpretation: Automatic interpretation of CPU status
- Recommendations: Suggestions based on current system state
CPU Status Interpretation
The Task Manager automatically interprets CPU status and provides recommendations:
| Status | Condition | Recommendation |
|---|---|---|
normal |
CPU operating normally | No action needed |
overloaded |
Pressure > 150% | Consider closing applications or upgrading hardware |
high_pressure |
Pressure > 100% and usage > 50% | CPU is working hard - monitor temperature |
throttled |
Usage > 80% but clock < 50% | CPU is throttled - check power settings and thermal management |
inefficient |
Usage < 20% but clock > 80% | Consider enabling power saving mode to reduce clock speed |
API Reference
getCPUMetrics()
Get current CPU metrics including usage, pressure, clock speeds, and interpretation.
const metrics = taskManager.getCPUMetrics();
console.log(`Usage: ${metrics.usagePercent}%`);
console.log(`Pressure: ${metrics.pressure}%`);
console.log(`Clock: ${metrics.clockSpeed} MHz`);
console.log(`Status: ${metrics.interpretation.status}`);
console.log(`Message: ${metrics.interpretation.message}`);
getMemoryMetrics()
Get current memory metrics.
const memory = taskManager.getMemoryMetrics();
console.log(`Used: ${memory.used / 1024 / 1024} MB`);
console.log(`Free: ${memory.free / 1024 / 1024} MB`);
console.log(`Usage: ${memory.usagePercent}%`);
getProcessList()
Get list of all running processes.
const processes = taskManager.getProcessList();
processes.forEach(proc => {
console.log(`${proc.name} (PID: ${proc.pid}): ${proc.cpuUsage}% CPU, ${proc.memoryUsage} bytes`);
});
getAllMetrics()
Get all metrics (CPU, memory, network, processes) in one call.
const allMetrics = taskManager.getAllMetrics();
console.log('CPU:', allMetrics.cpu);
console.log('Memory:', allMetrics.memory);
console.log('Processes:', allMetrics.processes.length);
start()
Start monitoring (updates every second).
taskManager.start();
stop()
Stop monitoring.
taskManager.stop();
Integration
The Task Manager integrates with:
- FreeWorldSystem: Initialized in
system/integration.js - logd: Logs monitoring events
- Resource Manager: Can integrate with kernel resource manager for accurate metrics
- HAL: Uses HAL for CPU and memory detection
UI Components
The Task Manager UI (system/task-manager-ui.js) provides:
- Performance Tab: Dual CPU gauges, memory gauge, detailed metrics
- Processes Tab: Process list with CPU and memory usage
- Services Tab: Integration with Services Manager (future)
- Real-time Updates: Automatic refresh every second
Usage Example
const FreeWorldSystem = require('./system/integration');
const system = new FreeWorldSystem();
await system.init();
const taskManager = system.getTaskManager();
// Start monitoring
taskManager.start();
// Get CPU metrics
const cpu = taskManager.getCPUMetrics();
console.log(`CPU Usage: ${cpu.usagePercent}%`);
console.log(`CPU Pressure: ${cpu.pressure}%`);
console.log(`Clock Speed: ${cpu.clockSpeed} MHz / ${cpu.maxClockSpeed} MHz`);
console.log(`Status: ${cpu.interpretation.status}`);
console.log(`Message: ${cpu.interpretation.message}`);
console.log(`Recommendation: ${cpu.interpretation.recommendation}`);
// Get all metrics
const metrics = taskManager.getAllMetrics();
console.log('All metrics:', metrics);