diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 0000000..e3d0554 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,24 @@ +cff-version: 1.2.0 +message: "If you use this software, please cite it as below." +type: software +title: "PSS: A Browser-Based Interactive Simulator for CPU Scheduling Algorithms" +version: 1.2.0 +date-released: "2026-03-23" +license: MIT +url: "https://pss.lucasrguerra.dev.br" +repository-code: "https://github.com/lucasrguerra/pss" +authors: + - family-names: Guerra + given-names: Lucas Rayan + orcid: "https://orcid.org/0009-0002-3170-4126" + affiliation: "Universidade Federal Rural de Pernambuco (UFRPE), Brazil" + email: lucas.guerra@ufrpe.br +keywords: + - operating systems + - CPU scheduling + - process scheduling + - computer science education + - simulation + - visualization + - TypeScript + - React diff --git a/README.en.md b/README.en.md index f6a7ec5..41bdc6e 100644 --- a/README.en.md +++ b/README.en.md @@ -13,7 +13,7 @@ ## ✨ What is it? -The **Process Scheduler Simulator (PSS)** runs entirely in the browser — no server, no system dependencies. You define the processes, choose the algorithm, and watch the simulation unfold in real time through the Gantt chart. +The **Process Scheduler Simulator (PSS)** runs entirely in the browser, completely free of servers and system dependencies. You define the processes, choose the algorithm, and watch the simulation unfold in real time through the Gantt chart. Ideal for: - 📚 Operating Systems students who want to visualize what was once only theory @@ -64,10 +64,10 @@ docker compose up ## 🎮 How to use -1. **Create your processes** — In the left panel, add processes by defining name, arrival time, priority, and a sequence of bursts (CPU and I/O). Or use the random generator to get started quickly. -2. **Configure the scheduler** — Choose an algorithm and adjust the parameters (quantum for RR, aging for Priority, etc.). -3. **Run the simulation** — Use the Play/Pause/Step controls to run the simulation at the speed you want (0.25× to 4×). -4. **Analyze the results** — The Gantt chart shows each process's state in real time. At the end, the metrics panel displays turnaround, waiting time, throughput, and more. +1. **Create your processes**: In the left panel, add processes by defining name, arrival time, priority, and a sequence of bursts (CPU and I/O). Or use the random generator to get started quickly. +2. **Configure the scheduler**: Choose an algorithm and adjust the parameters (quantum for RR, aging for Priority, etc.). +3. **Run the simulation**: Use the Play/Pause/Step controls to run the simulation at the speed you want (0.25× to 4×). +4. **Analyze the results**: The Gantt chart shows each process's state in real time. At the end, the metrics panel displays turnaround, waiting time, throughput, and more. > 💡 **Tip:** Load one of the built-in **presets** to see classic phenomena such as the FCFS convoy effect or priority starvation. @@ -77,13 +77,13 @@ docker compose up | Algorithm | Preemptive? | Parameters | |-----------|:-----------:|------------| -| **FCFS** — First Come, First Served | ❌ | — | -| **SJF** — Shortest Job First | ❌ | — | -| **SRTF** — Shortest Remaining Time First | ✅ | — | +| **FCFS**: First Come, First Served | ❌ | None | +| **SJF**: Shortest Job First | ❌ | None | +| **SRTF**: Shortest Remaining Time First | ✅ | None | | **Round Robin (RR)** | ✅ | Quantum | -| **Priority NP** — Non-Preemptive Priority | ❌ | Aging (optional) | -| **Priority P** — Preemptive Priority | ✅ | Aging (optional) | -| **HRRN** — Highest Response Ratio Next | ❌ | — | +| **Priority NP**: Non-Preemptive Priority | ❌ | Aging (optional) | +| **Priority P**: Preemptive Priority | ✅ | Aging (optional) | +| **HRRN**: Highest Response Ratio Next | ❌ | None | | **Multilevel Queue** | ✅ | Quantum per queue | > See the [algorithms documentation](./docs/algorithms.en.md) for details on how each one works. @@ -94,12 +94,12 @@ docker compose up For each simulated process, PSS automatically computes: -- **Response Time** — time until the first CPU usage -- **Turnaround Time** — total time from arrival to completion -- **Waiting Time** — total time spent in the Ready queue -- **CPU Time / I/O Time** — effective time in each type of burst -- **CPU Utilization** — percentage of turnaround time spent on CPU -- **Bound Type** — automatic classification as CPU Bound, I/O Bound, or Balanced +- **Response Time**: time until the first CPU usage +- **Turnaround Time**: total time from arrival to completion +- **Waiting Time**: total time spent in the Ready queue +- **CPU Time / I/O Time**: effective time in each type of burst +- **CPU Utilization**: percentage of turnaround time spent on CPU +- **Bound Type**: automatic classification as CPU Bound, I/O Bound, or Balanced Globally: averages for response/turnaround/waiting, throughput, and overall CPU utilization. @@ -109,7 +109,7 @@ Globally: averages for response/turnaround/waiting, throughput, and overall CPU ``` src/ -├── core/ # Pure logic — no React +├── core/ # Pure logic (no React) │ ├── algorithms/ # Implementation of each algorithm │ │ ├── base.ts # Abstract class BaseScheduler │ │ ├── fcfs.ts @@ -120,7 +120,7 @@ src/ │ │ ├── hrrn.ts │ │ ├── multilevel.ts │ │ └── index.ts # Dispatch by algorithm -│ ├── engine.ts # SimulationEngine — orchestrates the ticks +│ ├── engine.ts # SimulationEngine, orchestrates the ticks │ ├── metrics.ts # Per-process and global metrics computation │ ├── types.ts # All TypeScript interfaces │ └── presets.ts # Pre-defined scenarios @@ -189,9 +189,9 @@ Tests cover the simulation engine, all scheduling algorithms, and metrics comput ## 📄 Additional Documentation -- [📐 Scheduling Algorithms](./docs/algorithms.en.md) — detailed description of each algorithm, tie-breaking rules, and examples -- [📏 Metrics](./docs/metrics.en.md) — formulas and definitions for all computed metrics -- [📝 JOSS Paper](./paper.md) — scientific paper submitted to the Journal of Open Source Software +- [📐 Scheduling Algorithms](./docs/algorithms.en.md): detailed description of each algorithm, tie-breaking rules, and examples +- [📏 Metrics](./docs/metrics.en.md): formulas and definitions for all computed metrics +- [📝 JOSS Paper](./paper.md): scientific paper submitted to the Journal of Open Source Software *Também disponível em: [🇧🇷 Português](./README.md)* diff --git a/README.md b/README.md index 31fa3c5..1db056f 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ ## ✨ O que é? -O **Process Scheduler Simulator (PSS)** roda completamente no navegador — sem servidor, sem instalação de dependências de sistema. Você define os processos, escolhe o algoritmo, e assiste à simulação acontecer em tempo real através do diagrama de Gantt. +O **Process Scheduler Simulator (PSS)** roda completamente no navegador, sem servidor e sem instalação de dependências de sistema. Você define os processos, escolhe o algoritmo, e assiste à simulação acontecer em tempo real através do diagrama de Gantt. Ideal para: - 📚 Estudantes de Sistemas Operacionais querendo visualizar o que antes era só teoria @@ -62,10 +62,10 @@ docker compose up ## 🎮 Como usar -1. **Crie seus processos** — No painel esquerdo, adicione processos definindo nome, tempo de chegada, prioridade e sequência de bursts (CPU e I/O). Ou use o gerador aleatório para começar rápido. -2. **Configure o escalonador** — Escolha o algoritmo e ajuste os parâmetros (quantum para RR, aging para Priority, etc.). -3. **Execute a simulação** — Use os controles de Play/Pause/Step para rodar a simulação na velocidade que quiser (0.25× até 4×). -4. **Analise os resultados** — O diagrama de Gantt mostra em tempo real o estado de cada processo. Ao final, o painel de métricas exibe turnaround, waiting time, throughput e mais. +1. **Crie seus processos**: No painel esquerdo, adicione processos definindo nome, tempo de chegada, prioridade e sequência de bursts (CPU e I/O). Ou use o gerador aleatório para começar rápido. +2. **Configure o escalonador**: Escolha o algoritmo e ajuste os parâmetros (quantum para RR, aging para Priority, etc.). +3. **Execute a simulação**: Use os controles de Play/Pause/Step para rodar a simulação na velocidade que quiser (0.25× até 4×). +4. **Analise os resultados**: O diagrama de Gantt mostra em tempo real o estado de cada processo. Ao final, o painel de métricas exibe turnaround, waiting time, throughput e mais. > 💡 **Dica:** Carregue um dos **presets** disponíveis para ver fenômenos clássicos como o efeito de comboio do FCFS ou starvation com Priority Scheduling. @@ -75,13 +75,13 @@ docker compose up | Algoritmo | Preemptivo? | Parâmetros | |-----------|:-----------:|------------| -| **FCFS** — First Come, First Served | ❌ | — | -| **SJF** — Shortest Job First | ❌ | — | -| **SRTF** — Shortest Remaining Time First | ✅ | — | +| **FCFS**: First Come, First Served | ❌ | Nenhum | +| **SJF**: Shortest Job First | ❌ | Nenhum | +| **SRTF**: Shortest Remaining Time First | ✅ | Nenhum | | **Round Robin (RR)** | ✅ | Quantum | -| **Priority NP** — Prioridade Não-Preemptivo | ❌ | Aging (opcional) | -| **Priority P** — Prioridade Preemptivo | ✅ | Aging (opcional) | -| **HRRN** — Highest Response Ratio Next | ❌ | — | +| **Priority NP**: Prioridade Não-Preemptiva | ❌ | Aging (opcional) | +| **Priority P**: Prioridade Preemptiva | ✅ | Aging (opcional) | +| **HRRN**: Highest Response Ratio Next | ❌ | Nenhum | | **Multilevel Queue** | ✅ | Quantum por fila | > Consulte a [documentação dos algoritmos](./docs/algorithms.md) para detalhes sobre como cada um funciona. @@ -92,12 +92,12 @@ docker compose up Para cada processo simulado, o PSS calcula automaticamente: -- **Response Time** — tempo até o primeiro uso de CPU -- **Turnaround Time** — tempo total desde a chegada até o término -- **Waiting Time** — tempo total na fila Ready -- **CPU Time / I/O Time** — tempo efetivo em cada tipo de burst -- **CPU Utilization** — percentual do turnaround em CPU -- **Bound Type** — classificação automática em CPU Bound, I/O Bound ou Balanced +- **Response Time**: tempo até o primeiro uso de CPU +- **Turnaround Time**: tempo total desde a chegada até o término +- **Waiting Time**: tempo total na fila Ready +- **CPU Time / I/O Time**: tempo efetivo em cada tipo de burst +- **CPU Utilization**: percentual do turnaround em CPU +- **Bound Type**: classificação automática em CPU Bound, I/O Bound ou Balanced E globalmente: médias de response/turnaround/waiting, throughput e utilização global de CPU. @@ -107,7 +107,7 @@ E globalmente: médias de response/turnaround/waiting, throughput e utilização ``` src/ -├── core/ # Lógica pura — sem React +├── core/ # Lógica pura (sem React) │ ├── algorithms/ # Implementação de cada algoritmo │ │ ├── base.ts # Classe abstrata BaseScheduler │ │ ├── fcfs.ts @@ -118,7 +118,7 @@ src/ │ │ ├── hrrn.ts │ │ ├── multilevel.ts │ │ └── index.ts # Dispatch por algoritmo -│ ├── engine.ts # SimulationEngine — orquestra os ticks +│ ├── engine.ts # SimulationEngine, orquestra os ticks │ ├── metrics.ts # Cálculo de métricas por processo e globais │ ├── types.ts # Todas as interfaces TypeScript │ └── presets.ts # Cenários pré-definidos @@ -187,9 +187,9 @@ Os testes cobrem a engine de simulação, todos os algoritmos de escalonamento, ## 📄 Documentação adicional -- [📐 Algoritmos de Escalonamento](./docs/algorithms.md) — descrição detalhada de cada algoritmo, regras de desempate e exemplos -- [📏 Métricas](./docs/metrics.md) — fórmulas e definições de todas as métricas calculadas -- [📝 JOSS Paper](./paper.md) — artigo científico submetido ao Journal of Open Source Software +- [📐 Algoritmos de Escalonamento](./docs/algorithms.md): descrição detalhada de cada algoritmo, regras de desempate e exemplos +- [📏 Métricas](./docs/metrics.md): fórmulas e definições de todas as métricas calculadas +- [📝 JOSS Paper](./paper.md): artigo científico submetido ao Journal of Open Source Software *Also available in: [🇺🇸 English](./README.en.md)* diff --git a/dist.tar.gz b/dist.tar.gz index f6b9c30..e051a69 100644 Binary files a/dist.tar.gz and b/dist.tar.gz differ diff --git a/docs/algorithms.en.md b/docs/algorithms.en.md index 2aca91f..6f994b4 100644 --- a/docs/algorithms.en.md +++ b/docs/algorithms.en.md @@ -15,13 +15,13 @@ This document describes in detail the scheduling algorithms implemented in PSS. --- -## FCFS — First Come, First Served +## FCFS (First Come, First Served) **Type:** Non-preemptive ### How it works -Perhaps the most intuitive algorithm: the process that arrived first is served first. The Ready queue is sorted by `arrivalTime`. Once a process occupies the CPU, it stays there until its current CPU burst is complete — no interruptions. +Perhaps the most intuitive algorithm: the process that arrived first is served first. The Ready queue is sorted by `arrivalTime`. Once a process occupies the CPU, it stays there until its current CPU burst is complete, with no interruptions. ### Example @@ -42,11 +42,11 @@ Tick: 0 1 2 3 4 5 6 7 ### Note: Convoy Effect -If a long process arrives before several short ones, the short ones wait a long time — even though the CPU could be serving them. This phenomenon is called the **Convoy Effect** and is one of the main drawbacks of FCFS. Try the `convoy_effect` preset to visualize it. +If a long process arrives before several short ones, the short ones wait a long time, even though the CPU could be serving them. This phenomenon is called the **Convoy Effect** and is one of the main drawbacks of FCFS. Try the `convoy_effect` preset to visualize it. --- -## SJF — Shortest Job First (Non-Preemptive) +## SJF (Shortest Job First - Non-Preemptive) **Type:** Non-preemptive @@ -62,7 +62,7 @@ No additional parameters. --- -## SRTF — Shortest Remaining Time First (Preemptive SJF) +## SRTF (Shortest Remaining Time First - Preemptive SJF) **Type:** Preemptive @@ -93,7 +93,7 @@ Tick 12: P1 finishes The Ready queue is treated as a circular queue. Each process receives at most `quantum` consecutive CPU ticks. If the process still has remaining burst at the end of the quantum, it goes back to the **end** of the Ready queue and waits its turn. -I/O bursts **do not** consume quantum — the process voluntarily leaves the CPU when initiating I/O. +I/O bursts **do not** consume quantum, as the process voluntarily leaves the CPU when initiating I/O. ### Trade-off @@ -123,7 +123,7 @@ Try the `starvation` and `aging_fix` presets to see this difference. --- -## HRRN — Highest Response Ratio Next +## HRRN (Highest Response Ratio Next) **Type:** Non-preemptive @@ -152,7 +152,7 @@ The process with the **highest ratio** is selected. This naturally increases the ### How it works -Processes are distributed across multiple queues with different priorities. Each queue has its own Round Robin quantum. Higher-priority queues are always served first — a lower-priority queue only receives CPU if all queues above it are empty. +Processes are distributed across multiple queues with different priorities. Each queue has its own Round Robin quantum. Higher-priority queues are always served first. A lower-priority queue only receives CPU if all queues above it are empty. This allows different classes of processes to be treated distinctly: for example, interactive processes in high-priority queues (small quantum) and batch processes in low-priority queues (larger quantum). @@ -160,5 +160,5 @@ This allows different classes of processes to be treated distinctly: for example ## References -- Silberschatz, A., Galvin, P. B., & Gagne, G. — *Operating System Concepts*, 10th edition -- Tanenbaum, A. S. — *Modern Operating Systems*, 4th edition +- Silberschatz, A., Galvin, P. B., & Gagne, G., *Operating System Concepts*, 10th edition. +- Tanenbaum, A. S., *Modern Operating Systems*, 4th edition. diff --git a/docs/algorithms.md b/docs/algorithms.md index 688cdfe..bf87831 100644 --- a/docs/algorithms.md +++ b/docs/algorithms.md @@ -15,13 +15,13 @@ Este documento descreve em detalhes os algoritmos de escalonamento implementados --- -## FCFS — First Come, First Served +## FCFS (First Come, First Served) **Tipo:** Não-preemptivo ### Como funciona -Talvez o algoritmo mais intuitivo: o processo que chegou primeiro é atendido primeiro. A fila Ready é ordenada por `arrivalTime`. Quando um processo ocupa a CPU, ele permanece lá até completar seu burst de CPU atual — sem interrupções. +Talvez o algoritmo mais intuitivo: o processo que chegou primeiro é atendido primeiro. A fila Ready é ordenada por `arrivalTime`. Quando um processo ocupa a CPU, ele permanece lá até completar seu burst de CPU atual, sem interrupções. ### Exemplo @@ -42,11 +42,11 @@ Tick: 0 1 2 3 4 5 6 7 ### Observação: Efeito de Comboio -Se um processo longo chega antes de vários processos curtos, estes ficam esperando por muito tempo — mesmo que a CPU esteja "disponível" para eles. Este fenômeno é chamado de **Convoy Effect** e é um dos principais problemas do FCFS. Experimente o preset `convoy_effect` para visualizá-lo. +Se um processo longo chega antes de vários processos curtos, estes ficam esperando por muito tempo, mesmo que a CPU esteja "disponível" para eles. Este fenômeno é chamado de **Convoy Effect** e é um dos principais problemas do FCFS. Experimente o preset `convoy_effect` para visualizá-lo. --- -## SJF — Shortest Job First (Não-Preemptivo) +## SJF (Shortest Job First - Não-Preemptivo) **Tipo:** Não-preemptivo @@ -62,7 +62,7 @@ Nenhum parâmetro adicional. --- -## SRTF — Shortest Remaining Time First (SJF Preemptivo) +## SRTF (Shortest Remaining Time First - SJF Preemptivo) **Tipo:** Preemptivo @@ -93,7 +93,7 @@ Tick 12: P1 termina A fila Ready é tratada como uma fila circular. Cada processo recebe no máximo `quantum` ticks de CPU consecutivos. Se ao final do quantum o processo ainda tiver burst restante, ele retorna ao **fim** da fila Ready e aguarda sua vez. -I/O bursts **não** consomem quantum — o processo sai voluntariamente da CPU quando inicia I/O. +I/O bursts **não** consomem quantum, pois o processo sai voluntariamente da CPU quando inicia I/O. ### Tradeoff @@ -123,7 +123,7 @@ Experimente os presets `starvation` e `aging_fix` para ver esta diferença. --- -## HRRN — Highest Response Ratio Next +## HRRN (Highest Response Ratio Next) **Tipo:** Não-preemptivo @@ -152,7 +152,7 @@ O processo com o **maior ratio** é selecionado. Isso faz com que processos que ### Como funciona -Os processos são distribuídos em múltiplas filas com diferentes prioridades. Cada fila tem seu próprio quantum de Round Robin. Filas de maior prioridade sempre são servidas primeiro — uma fila de menor prioridade só recebe CPU se todas as filas acima dela estiverem vazias. +Os processos são distribuídos em múltiplas filas com diferentes prioridades. Cada fila tem seu próprio quantum de Round Robin. Filas de maior prioridade sempre são servidas primeiro. Uma fila de menor prioridade só recebe CPU se todas as filas acima dela estiverem vazias. Isso permite tratar diferentes classes de processos de forma distinta: por exemplo, processos interativos em filas de alta prioridade (quantum pequeno) e processos batch em filas de baixa prioridade (quantum maior). @@ -160,5 +160,5 @@ Isso permite tratar diferentes classes de processos de forma distinta: por exemp ## Referências -- Silberschatz, A., Galvin, P. B., & Gagne, G. — *Operating System Concepts*, 10ª edição -- Tanenbaum, A. S. — *Modern Operating Systems*, 4ª edição +- Silberschatz, A., Galvin, P. B., & Gagne, G., *Operating System Concepts*, 10ª edição. +- Tanenbaum, A. S., *Modern Operating Systems*, 4ª edição. diff --git a/docs/metrics.en.md b/docs/metrics.en.md index 916785a..9f49e6a 100644 --- a/docs/metrics.en.md +++ b/docs/metrics.en.md @@ -79,7 +79,7 @@ otherwise → Balanced ## Charts ("Chart" tab) -### Comparative Profile — Radar Chart +### Comparative Profile (Radar Chart) Displayed when there are **2 or more processes**. Each axis represents a time dimension, normalized from 0–100% relative to the largest value in that dimension among all processes: @@ -91,15 +91,15 @@ Displayed when there are **2 or more processes**. Each axis represents a time di | **CPU Time** | Relative CPU usage | | **I/O Time** | Relative I/O usage | -Each process is drawn as a colored polygon (the color configured for the process). Wider polygons indicate processes with larger times in the corresponding dimensions. The radar chart is ideal for identifying **profile differences** between processes — for example, a CPU Bound process will have a much larger CPU Time axis than I/O Time. +Each process is drawn as a colored polygon (the color configured for the process). Wider polygons indicate processes with larger times in the corresponding dimensions. The radar chart is ideal for identifying **profile differences** between processes (for example, a CPU Bound process will have a much larger CPU Time axis than I/O Time). -### Per-Process Breakdown — Stacked Bar Chart +### Per-Process Breakdown (Stacked Bar Chart) Always displayed. Each bar represents a process, with stacked segments: -- **Amber** — Waiting Time -- **Green** — CPU Time -- **Cyan** — I/O Time +- **Amber**: Waiting Time +- **Green**: CPU Time +- **Cyan**: I/O Time The total height of each bar equals the **Turnaround Time** of the process. diff --git a/docs/metrics.md b/docs/metrics.md index 69e6e90..b664aae 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -79,7 +79,7 @@ caso contrário → Balanced ## Gráficos (aba "Gráfico") -### Perfil Comparativo — Radar Chart +### Perfil Comparativo (Radar Chart) Exibido quando há **2 ou mais processos**. Cada eixo representa uma dimensão de tempo, normalizada de 0–100% em relação ao maior valor dessa dimensão entre todos os processos: @@ -91,15 +91,15 @@ Exibido quando há **2 ou mais processos**. Cada eixo representa uma dimensão d | **CPU Time** | Uso de CPU relativo | | **I/O Time** | Uso de I/O relativo | -Cada processo é desenhado como um polígono colorido (a cor configurada no processo). Polígonos mais "amplos" indicam processos com tempos maiores nas dimensões correspondentes. O radar é ideal para identificar **diferenças de perfil** entre processos — por exemplo, um processo CPU Bound terá o eixo CPU Time muito maior que o eixo I/O Time. +Cada processo é desenhado como um polígono colorido (a cor configurada no processo). Polígonos mais "amplos" indicam processos com tempos maiores nas dimensões correspondentes. O radar é ideal para identificar **diferenças de perfil** entre processos (por exemplo, um processo CPU Bound terá o eixo CPU Time muito maior que o eixo I/O Time). -### Breakdown por Processo — Stacked Bar Chart +### Breakdown por Processo (Stacked Bar Chart) Sempre exibido. Cada barra representa um processo, com os segmentos empilhados: -- **Âmbar** — Waiting Time -- **Verde** — CPU Time -- **Ciano** — I/O Time +- **Âmbar**: Waiting Time +- **Verde**: CPU Time +- **Ciano**: I/O Time A altura total de cada barra equivale ao **Turnaround Time** do processo. diff --git a/index.html b/index.html index 45d3bde..5485c24 100644 --- a/index.html +++ b/index.html @@ -1,9 +1,9 @@ - + - + Process Scheduler Simulator diff --git a/package-lock.json b/package-lock.json index d97c9fa..ba8dc44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,13 @@ { "name": "pss", - "version": "1.0.0", + "version": "1.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "pss", - "version": "1.0.0", - "license": "ISC", + "version": "1.2.0", + "license": "MIT", "dependencies": { "clsx": "^2.1.1", "lucide-react": "^0.577.0", @@ -147,7 +147,6 @@ "integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.29.0", "@babel/generator": "^7.29.0", @@ -520,7 +519,6 @@ } ], "license": "MIT", - "peer": true, "engines": { "node": ">=20.19.0" }, @@ -569,7 +567,6 @@ } ], "license": "MIT", - "peer": true, "engines": { "node": ">=20.19.0" } @@ -1895,7 +1892,8 @@ "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz", "integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==", "dev": true, - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/@types/babel__core": { "version": "7.20.5", @@ -2036,7 +2034,6 @@ "integrity": "sha512-jp2P3tQMSxWugkCUKLRPVUpGaL5MVFwF8RDuSRztfwgN1wmqJeMSbKlnEtQqU8UrhTmzEmZdu2I6v2dpp7XIxw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "undici-types": "~7.18.0" } @@ -2054,7 +2051,6 @@ "integrity": "sha512-z9VXpC7MWrhfWipitjNdgCauoMLRdIILQsAEV+ZesIzBq/oUlxk0m3ApZuMFCXdnS4U7KrI+l3WRUEGQ8K1QKw==", "devOptional": true, "license": "MIT", - "peer": true, "dependencies": { "@types/prop-types": "*", "csstype": "^3.2.2" @@ -2066,7 +2062,6 @@ "integrity": "sha512-MEe3UeoENYVFXzoXEWsvcpg6ZvlrFNlOQ7EOsvhI3CfAXwzPfO8Qwuxd40nepsYKqyyVQnTdEfv68q91yLcKrQ==", "dev": true, "license": "MIT", - "peer": true, "peerDependencies": { "@types/react": "^18.0.0" } @@ -2378,7 +2373,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -2731,7 +2725,8 @@ "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz", "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==", "dev": true, - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/eastasianwidth": { "version": "0.2.0", @@ -3549,6 +3544,7 @@ "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==", "dev": true, "license": "MIT", + "peer": true, "bin": { "lz-string": "bin/bin.js" } @@ -3764,7 +3760,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -3807,6 +3802,7 @@ "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "ansi-regex": "^5.0.1", "ansi-styles": "^5.0.0", @@ -3822,6 +3818,7 @@ "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=8" } @@ -3832,6 +3829,7 @@ "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=10" }, @@ -3854,7 +3852,6 @@ "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", "license": "MIT", - "peer": true, "dependencies": { "loose-envify": "^1.1.0" }, @@ -3867,7 +3864,6 @@ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz", "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", "license": "MIT", - "peer": true, "dependencies": { "loose-envify": "^1.1.0", "scheduler": "^0.23.2" @@ -3888,7 +3884,6 @@ "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.2.0.tgz", "integrity": "sha512-ROY9fvHhwOD9ySfrF0wmvu//bKCQ6AeZZq1nJNtbDC+kk5DuSuNX/n6YWYF/SYy7bSba4D4FSz8DJeKY/S/r+g==", "license": "MIT", - "peer": true, "dependencies": { "@types/use-sync-external-store": "^0.0.6", "use-sync-external-store": "^1.4.0" @@ -3965,8 +3960,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz", "integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/redux-thunk": { "version": "3.1.0", @@ -4552,7 +4546,6 @@ "integrity": "sha512-+Oxm7q9hDoLMyJOYfUYBuHQo+dkAloi33apOPP56pzj+vsdJDzr+j1NISE5pyaAuKL4A3UD34qd0lx5+kfKp2g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.4.4", @@ -4651,7 +4644,6 @@ "integrity": "sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@types/chai": "^5.2.2", "@vitest/expect": "3.2.4", diff --git a/package.json b/package.json index b24748e..99bfb9f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pss", - "version": "1.1.0", - "description": "O Process Scheduler Simulator é uma ferramenta educacional interativa que roda inteiramente no navegador", + "version": "1.2.0", + "description": "Process Scheduler Simulator — an interactive educational tool that runs entirely in the browser", "main": "index.js", "scripts": { "dev": "vite", diff --git a/paper.md b/paper.md index e1ac23e..ed60525 100644 --- a/paper.md +++ b/paper.md @@ -23,7 +23,7 @@ bibliography: references.bib # Summary -The **Process Scheduler Simulator (PSS)** is an open-source, browser-based interactive tool designed to help students, instructors, and practitioners understand and compare classical CPU scheduling algorithms from the field of Operating Systems (OS). PSS runs entirely client-side — no server, no installation — making it instantly accessible via any modern web browser at [https://pss.lucasrguerra.dev.br](https://pss.lucasrguerra.dev.br). +The **Process Scheduler Simulator (PSS)** is an open-source, browser-based interactive tool designed to help students, instructors, and practitioners understand and compare classical CPU scheduling algorithms from the field of Operating Systems (OS). PSS runs entirely client-side, requiring no server or installation, which makes it instantly accessible via any modern web browser at [https://pss.lucasrguerra.dev.br](https://pss.lucasrguerra.dev.br). Users define a set of processes, each with an arbitrary sequence of alternating CPU and I/O bursts, and select one of eight scheduling algorithms. The simulator then executes the schedule tick by tick, rendering a live Gantt chart and computing a comprehensive set of performance metrics for each process and for the simulation as a whole. PSS supports First Come First Served (FCFS), Shortest Job First (SJF), Shortest Remaining Time First (SRTF), Round Robin (RR), non-preemptive and preemptive Priority Scheduling (with optional aging), Highest Response Ratio Next (HRRN), and Multilevel Queue scheduling. @@ -39,13 +39,13 @@ PSS addresses this gap by providing a zero-installation, zero-configuration simu - **Instructors** seeking a live, configurable demonstration tool for classroom or remote teaching; - **Researchers and practitioners** who need a quick, reproducible environment to illustrate scheduling concepts. -The configurable parameters — quantum for Round Robin, aging interval and threshold for Priority Scheduling, and per-queue quantum for Multilevel — enable learners to observe how parameter choices affect fairness, throughput, and starvation, all within a single interactive session. +The configurable parameters (such as quantum for Round Robin, aging interval and threshold for Priority Scheduling, and per-queue quantum for Multilevel) enable learners to observe how parameter choices affect fairness, throughput, and starvation, all within a single interactive session. # State of the Field Several browser-based and desktop scheduling simulators exist. OS-sim [@ossim] offers a graphical simulation of a full operating system, including scheduling, but targets upper-division students and requires local installation. The CPU Scheduling Simulator by Mitchell [@mitchelljava] is a Java desktop application that covers a subset of algorithms without I/O burst modeling. Web-based tools such as Process Scheduling Simulator by Nikhil Anand cover FCFS, SJF, and RR, but do not support aging, HRRN, or Multilevel Queue, and lack composable I/O burst sequences. -PSS distinguishes itself in three key ways. First, it models **full CPU-I/O burst sequences** for each process, rather than a single CPU burst, enabling simulation of realistic workloads and the CPU Bound vs. I/O Bound classification. Second, it implements a broader set of algorithms — including HRRN and Multilevel Queue with per-queue quantum — than most comparable tools. Third, the entire application is deployed as a **static single-page application** with no backend dependency, enabling one-click access and offline use via Docker, which lowers the barrier for classroom adoption. +PSS distinguishes itself in three key ways. First, it models **full CPU-I/O burst sequences** for each process, rather than a single CPU burst, enabling simulation of realistic workloads and the CPU Bound vs. I/O Bound classification. Second, it implements a broader set of algorithms than most comparable tools, including HRRN and Multilevel Queue with per-queue quantum. Third, the entire application is deployed as a **static single-page application** with no backend dependency, enabling one-click access and offline use via Docker, which lowers the barrier for classroom adoption. # Software Design @@ -65,7 +65,7 @@ PSS was developed as part of the Computer Science undergraduate program at the U The availability of PSS as a fully open-source project under the MIT license, with Docker and `npm run dev` deployment paths, enables any institution to adopt or adapt the simulator without cost or proprietary dependency. The live deployment at [https://pss.lucasrguerra.dev.br](https://pss.lucasrguerra.dev.br) provides a stable public URL suitable for sharing in syllabi, assignments, and online course materials. -The built-in preset scenarios — including `convoy_effect`, `starvation`, and `aging_fix` — provide reproducible, named examples of classical OS phenomena that instructors can reference directly in lectures, assignments, or exam questions, facilitating standardized discussion of algorithm trade-offs. +The built-in preset scenarios, which include `convoy_effect`, `starvation`, and `aging_fix`, provide reproducible, named examples of classical OS phenomena that instructors can reference directly in lectures, assignments, or exam questions, facilitating standardized discussion of algorithm trade-offs. # AI Usage Disclosure @@ -73,6 +73,6 @@ The author used AI-assisted coding tools (GitHub Copilot and Google Gemini) duri # Acknowledgements -The author thanks the professors and students of the Operating Systems course at UFRPE whose feedback shaped the features and usability of PSS. +This software was developed to address specific requirements identified during a personal case study. The author acknowledges the professors and students of the Operating Systems course at UFRPE for their valuable comments and feedback provided after the tool was presented. # References diff --git a/references.bib b/references.bib index bb65bd3..9846ee2 100644 --- a/references.bib +++ b/references.bib @@ -36,7 +36,7 @@ author = {Robbins, Kay A.}, title = {{OS-sim}: A Graphical, Interprocess Operating System Simulator}, year = {2012}, - howpublished = {\url{https://github.com/mayank-02/multithreading-library}}, + howpublished = {\url{https://sourceforge.net/projects/oscsimulator/}}, note = {Used in OS coursework at several universities} } diff --git a/src/components/ControlBar/ControlBar.tsx b/src/components/ControlBar/ControlBar.tsx index 7269ef2..95e5dea 100644 --- a/src/components/ControlBar/ControlBar.tsx +++ b/src/components/ControlBar/ControlBar.tsx @@ -15,10 +15,10 @@ const SPEED_LABELS: Record = { }; const statusLabel: Record = { - idle: 'Pronto', - paused: 'Pausado', - running: 'Executando', - finished: 'Concluído', + idle: 'Ready', + paused: 'Paused', + running: 'Running', + finished: 'Finished', }; const statusDotClass: Record = { @@ -68,7 +68,7 @@ const ControlBar = () => {
{/* Left group: simulation controls */}
@@ -85,7 +85,7 @@ const ControlBar = () => { {/* Step */} { {/* Play / Pause */} {isRunning ? ( { ) : ( {
Tick {
- PSS v1.0 + PSS v1.2.0
); diff --git a/src/components/MetricsPanel/GlobalMetrics.tsx b/src/components/MetricsPanel/GlobalMetrics.tsx index 1f2899c..4eb03b3 100644 --- a/src/components/MetricsPanel/GlobalMetrics.tsx +++ b/src/components/MetricsPanel/GlobalMetrics.tsx @@ -70,7 +70,7 @@ const GlobalMetrics = ({ metrics }: GlobalMetricsProps) => { } @@ -79,7 +79,7 @@ const GlobalMetrics = ({ metrics }: GlobalMetricsProps) => { } @@ -88,7 +88,7 @@ const GlobalMetrics = ({ metrics }: GlobalMetricsProps) => { } @@ -97,7 +97,7 @@ const GlobalMetrics = ({ metrics }: GlobalMetricsProps) => { } @@ -120,7 +120,7 @@ const GlobalMetrics = ({ metrics }: GlobalMetricsProps) => { {utilizationPct.toFixed(1)}% - do tempo total em CPU + of total CPU time
{ if (metrics.length === 0) { return (
- Nenhum dado disponível. + No data available.
); } @@ -40,6 +40,35 @@ const MetricsChart = ({ metrics, processMap }: MetricsChartProps) => { const getName = (id: string) => processMap[id]?.name ?? id; const getColor = (id: string) => processMap[id]?.color ?? '#94a3b8'; + // Reverse map: process name → process (for radar tooltip lookup) + const nameToProcess = Object.fromEntries( + Object.values(processMap).map(p => [p.name, p]) + ); + + const radarTooltipContent = ({ active, payload, label }: { active?: boolean; payload?: readonly any[]; label?: string | number }) => { + if (!active || !payload?.length) return null; + return ( +
+

+ {label} +

+ {payload.map((entry: any) => { + const proc = nameToProcess[entry.name]; + const displayName = proc?.pid != null ? `#${proc.pid} ${proc.name}` : entry.name; + return ( +
+ + {displayName} + + {typeof entry.value === 'number' ? `${entry.value.toFixed(1)}%` : '-'} + +
+ ); + })} +
+ ); + }; + // ── Stacked bar data ────────────────────────────────────────── const barData = metrics.map((m) => ({ name: getName(m.processId), @@ -87,9 +116,9 @@ const MetricsChart = ({ metrics, processMap }: MetricsChartProps) => { {showRadar && (

- Perfil Comparativo (normalizado) + Comparative Profile (normalized)

- + { dot={{ r: 3, fill: getColor(m.processId) }} /> ))} - [typeof value === 'number' ? `${value.toFixed(1)}%` : '-', '']} - /> + @@ -123,9 +149,9 @@ const MetricsChart = ({ metrics, processMap }: MetricsChartProps) => { {/* ── Stacked bar chart ─────────────────────────────────── */}

- Breakdown por Processo (ticks) + Breakdown per Process (ticks)

- + }, + { id: 'table', label: 'Per Process', icon: }, { id: 'global', label: 'Global', icon: }, - { id: 'chart', label: 'Gráfico', icon: }, + { id: 'charts', label: 'Charts', icon: }, ]; const MetricsPanel = () => { @@ -31,7 +31,7 @@ const MetricsPanel = () => { if (!hasData) { return (
- Execute a simulação para ver as métricas. + Run the simulation to see metrics.
); } @@ -46,7 +46,7 @@ const MetricsPanel = () => { const canExportCSV = status === 'finished' && processMetrics.length > 0; return ( -
+
{/* Panel header with tabs + export button */}
{TAB_CONFIG.map(tab => ( @@ -69,9 +69,9 @@ const MetricsPanel = () => {
diff --git a/src/components/MetricsPanel/MetricsTable.tsx b/src/components/MetricsPanel/MetricsTable.tsx index 58cc1d0..179595d 100644 --- a/src/components/MetricsPanel/MetricsTable.tsx +++ b/src/components/MetricsPanel/MetricsTable.tsx @@ -22,7 +22,7 @@ interface MiniBarProps { const MiniBar = ({ value, max, color }: MiniBarProps) => { const pct = max > 0 ? (value / max) * 100 : 0; return ( -
+
{ if (metrics.length === 0) { return (
- Nenhum processo concluído ainda. + No completed processes yet.
); } @@ -50,10 +50,10 @@ const MetricsTable = ({ metrics, processMap }: MetricsTableProps) => { return (
-
+
- + diff --git a/src/components/ProcessPanel/ProcessCard.tsx b/src/components/ProcessPanel/ProcessCard.tsx index 92e40ab..82758af 100644 --- a/src/components/ProcessPanel/ProcessCard.tsx +++ b/src/components/ProcessPanel/ProcessCard.tsx @@ -56,7 +56,7 @@ const ProcessCard = ({ process, onEdit, onRemove }: ProcessCardProps) => { onEdit(process)} > @@ -64,7 +64,7 @@ const ProcessCard = ({ process, onEdit, onRemove }: ProcessCardProps) => { onRemove(process.id)} className="hover:text-red-400 hover:bg-red-900/20" > diff --git a/src/components/ProcessPanel/ProcessForm.tsx b/src/components/ProcessPanel/ProcessForm.tsx index edd1d58..37c8865 100644 --- a/src/components/ProcessPanel/ProcessForm.tsx +++ b/src/components/ProcessPanel/ProcessForm.tsx @@ -69,16 +69,16 @@ const ProcessForm = ({ editingProcess, onClose }: ProcessFormProps) => { const validate = (): boolean => { const errs: string[] = []; - if (!name.trim()) errs.push('Nome é obrigatório'); - if (name.trim().length > 8) errs.push('Nome deve ter no máximo 8 caracteres'); - if (arrivalTime < 0) errs.push('Arrival Time deve ser ≥ 0'); - if (priority < 1 || priority > 10) errs.push('Priority deve estar entre 1 e 10'); - if (bursts.length === 0) errs.push('Deve haver ao menos 1 burst CPU'); - if (bursts[0]?.type !== 'cpu') errs.push('O primeiro burst deve ser CPU'); - if (bursts.at(-1)?.type !== 'cpu') errs.push('O último burst deve ser CPU'); + if (!name.trim()) errs.push('Name is required'); + if (name.trim().length > 8) errs.push('Name must be at most 8 characters'); + if (arrivalTime < 0) errs.push('Arrival Time must be ≥ 0'); + if (priority < 1 || priority > 10) errs.push('Priority must be between 1 and 10'); + if (bursts.length === 0) errs.push('There must be at least 1 CPU burst'); + if (bursts[0]?.type !== 'cpu') errs.push('The first burst must be CPU'); + if (bursts.at(-1)?.type !== 'cpu') errs.push('The last burst must be CPU'); bursts.forEach((b, i) => { - if (b.duration < 1) errs.push(`Burst ${i + 1}: duração deve ser ≥ 1`); - if (i > 0 && bursts[i - 1]?.type === b.type) errs.push(`Bursts ${i} e ${i + 1} não podem ser do mesmo tipo (alternar CPU/IO)`); + if (b.duration < 1) errs.push(`Burst ${i + 1}: duration must be ≥ 1`); + if (i > 0 && bursts[i - 1]?.type === b.type) errs.push(`Bursts ${i} and ${i + 1} cannot be the same type (alternate CPU/IO)`); }); setErrors(errs); return errs.length === 0; @@ -108,9 +108,9 @@ const ProcessForm = ({ editingProcess, onClose }: ProcessFormProps) => {

- {isEditing ? 'Editar Processo' : 'Novo Processo'} + {isEditing ? 'Edit Process' : 'New Process'}

- +
@@ -120,7 +120,7 @@ const ProcessForm = ({ editingProcess, onClose }: ProcessFormProps) => {
{/* Name */}
- + { onChange={e => setName(e.target.value)} placeholder="P1" className={inputCls} - aria-label="Nome do processo" + aria-label="Process name" />
{/* Color */}
- + setColor(e.target.value)} className="h-8.5 w-12 rounded-md border border-slate-600 bg-slate-700 cursor-pointer" - aria-label="Cor do processo" + aria-label="Process color" />
@@ -156,7 +156,7 @@ const ProcessForm = ({ editingProcess, onClose }: ProcessFormProps) => { value={arrivalTime} onChange={e => setArrivalTime(Number(e.target.value))} className={inputCls} - aria-label="Tempo de chegada" + aria-label="Arrival time" />
@@ -171,7 +171,7 @@ const ProcessForm = ({ editingProcess, onClose }: ProcessFormProps) => { value={priority} onChange={e => setPriority(Number(e.target.value))} className={inputCls} - aria-label="Prioridade do processo" + aria-label="Process priority" /> @@ -180,7 +180,7 @@ const ProcessForm = ({ editingProcess, onClose }: ProcessFormProps) => {
- +
@@ -203,13 +203,13 @@ const ProcessForm = ({ editingProcess, onClose }: ProcessFormProps) => { value={burst.duration} onChange={e => updateBurstDuration(idx, Number(e.target.value))} className="w-full rounded bg-slate-700/60 border border-slate-600/50 text-slate-200 text-xs px-2 py-0.5 focus:outline-none focus:ring-1 focus:ring-blue-500" - aria-label={`Duração do burst ${idx + 1}`} + aria-label={`Burst ${idx + 1} duration`} /> ticks removeBurst(idx)} disabled={bursts.length <= 1} className="hover:text-red-400" @@ -235,17 +235,17 @@ const ProcessForm = ({ editingProcess, onClose }: ProcessFormProps) => {
diff --git a/src/components/ProcessPanel/ProcessList.tsx b/src/components/ProcessPanel/ProcessList.tsx index b964963..f808fce 100644 --- a/src/components/ProcessPanel/ProcessList.tsx +++ b/src/components/ProcessPanel/ProcessList.tsx @@ -47,13 +47,13 @@ const ProcessList = ({ onEditProcess, onAddNew }: ProcessListProps) => { {/* List header */}
- {processes.length}/{MAX_PROCESSES} processos + {processes.length}/{MAX_PROCESSES} processes
@@ -62,7 +62,7 @@ const ProcessList = ({ onEditProcess, onAddNew }: ProcessListProps) => { {
{processes.length === 0 ? (
- Nenhum processo adicionado - Clique em + para criar + No processes added + Click + to create
) : ( processes.map(p => ( @@ -95,11 +95,11 @@ const ProcessList = ({ onEditProcess, onAddNew }: ProcessListProps) => { {canAdd && ( )}
diff --git a/src/components/ProcessPanel/ProcessPanel.tsx b/src/components/ProcessPanel/ProcessPanel.tsx index 920df9a..4c3fb11 100644 --- a/src/components/ProcessPanel/ProcessPanel.tsx +++ b/src/components/ProcessPanel/ProcessPanel.tsx @@ -24,10 +24,10 @@ const ProcessPanel = () => { }; return ( -
+
-

Processos

+

Processes

{showForm ? ( diff --git a/src/components/SchedulerPanel/AlgorithmSelector.tsx b/src/components/SchedulerPanel/AlgorithmSelector.tsx index abc9f67..c60b7e7 100644 --- a/src/components/SchedulerPanel/AlgorithmSelector.tsx +++ b/src/components/SchedulerPanel/AlgorithmSelector.tsx @@ -6,9 +6,9 @@ const ALGORITHM_OPTIONS: { value: SchedulingAlgorithm; label: string; disabled?: { value: 'SJF_NP', label: 'SJF — Shortest Job First (NP)' }, { value: 'SJF_P', label: 'SRTF — Shortest Remaining Time (P)' }, { value: 'RR', label: 'RR — Round Robin' }, - { value: 'PRIORITY_NP',label: 'Priority (Não-preemptivo)' }, - { value: 'PRIORITY_P', label: 'Priority (Preemptivo)' }, - { value: 'PRIORITY_RR',label: 'Priority Round Robin (tempo real)' }, + { value: 'PRIORITY_NP',label: 'Priority (Non-preemptive)' }, + { value: 'PRIORITY_P', label: 'Priority (Preemptive)' }, + { value: 'PRIORITY_RR',label: 'Priority Round Robin (real-time)' }, { value: 'HRRN', label: 'HRRN — Highest Response Ratio Next' }, { value: 'MULTILEVEL', label: 'Multilevel Queue (MLQ)' }, ]; @@ -23,14 +23,14 @@ const AlgorithmSelector = () => { htmlFor="algorithm-select" className="block text-xs text-slate-400 mb-1" > - Algoritmo + Algorithm update(idx, { priorityMin: Math.min(10, Math.max(1, Number(e.target.value))) })} className="w-full rounded bg-slate-700 border border-slate-600 text-slate-200 text-xs px-2 py-1 focus:outline-none focus:ring-1 focus:ring-blue-500" - aria-label={`Fila ${idx}: prioridade mínima`} + aria-label={`Queue ${idx}: minimum priority`} />
- + update(idx, { priorityMax: Math.min(10, Math.max(1, Number(e.target.value))) })} className="w-full rounded bg-slate-700 border border-slate-600 text-slate-200 text-xs px-2 py-1 focus:outline-none focus:ring-1 focus:ring-blue-500" - aria-label={`Fila ${idx}: prioridade máxima`} + aria-label={`Queue ${idx}: maximum priority`} />
- + { value={config.agingInterval} onChange={e => setConfig({ agingInterval: Math.max(1, Number(e.target.value)) })} className={inputCls} - aria-label="Intervalo de aging" + aria-label="Aging interval" />
)} diff --git a/src/components/SchedulerPanel/SchedulerPanel.tsx b/src/components/SchedulerPanel/SchedulerPanel.tsx index 0ff7125..c02b27f 100644 --- a/src/components/SchedulerPanel/SchedulerPanel.tsx +++ b/src/components/SchedulerPanel/SchedulerPanel.tsx @@ -4,10 +4,10 @@ import SchedulerConfig from './SchedulerConfig'; const SchedulerPanel = () => { return ( -
+
-

Escalonador

+

Scheduler

diff --git a/src/components/__tests__/ControlBar.test.tsx b/src/components/__tests__/ControlBar.test.tsx index 5ee17c2..2cdd9de 100644 --- a/src/components/__tests__/ControlBar.test.tsx +++ b/src/components/__tests__/ControlBar.test.tsx @@ -38,9 +38,9 @@ describe('ControlBar', () => { expect(screen.getByTestId('tick-display')).toHaveTextContent('0000'); }); - it('shows "Pronto" status when idle', () => { + it('shows "Ready" status when idle', () => { render(); - expect(screen.getByText('Pronto')).toBeInTheDocument(); + expect(screen.getByText('Ready')).toBeInTheDocument(); }); it('Play button is disabled when no processes are loaded', () => { diff --git a/src/components/__tests__/ProcessForm.test.tsx b/src/components/__tests__/ProcessForm.test.tsx index 455ad0b..4b9b20e 100644 --- a/src/components/__tests__/ProcessForm.test.tsx +++ b/src/components/__tests__/ProcessForm.test.tsx @@ -11,62 +11,62 @@ beforeEach(() => { }); describe('ProcessForm', () => { - it('renders the "Novo Processo" form with default fields', () => { + it('renders the "New Process" form with default fields', () => { render( {}} />); expect(screen.getByTestId('process-form')).toBeInTheDocument(); - expect(screen.getByText('Novo Processo')).toBeInTheDocument(); - expect(screen.getByLabelText('Nome do processo')).toBeInTheDocument(); - expect(screen.getByLabelText('Tempo de chegada')).toBeInTheDocument(); - expect(screen.getByLabelText('Prioridade do processo')).toBeInTheDocument(); + expect(screen.getByText('New Process')).toBeInTheDocument(); + expect(screen.getByLabelText('Process name')).toBeInTheDocument(); + expect(screen.getByLabelText('Arrival time')).toBeInTheDocument(); + expect(screen.getByLabelText('Process priority')).toBeInTheDocument(); }); - it('shows "Editar Processo" title when editingProcess is provided', () => { + it('shows "Edit Process" title when editingProcess is provided', () => { const proc = { id: 'p1', name: 'P1', arrivalTime: 0, priority: 5, color: '#fff', bursts: [{ type: 'cpu' as const, duration: 4 }], }; render( {}} />); - expect(screen.getByText('Editar Processo')).toBeInTheDocument(); + expect(screen.getByText('Edit Process')).toBeInTheDocument(); }); it('shows validation error when name is empty', async () => { const user = userEvent.setup(); render( {}} />); - const nameInput = screen.getByLabelText('Nome do processo'); + const nameInput = screen.getByLabelText('Process name'); await user.clear(nameInput); - const submitBtn = screen.getByRole('button', { name: /Criar/i }); + const submitBtn = screen.getByRole('button', { name: /Create/i }); await user.click(submitBtn); expect(screen.getByRole('alert')).toBeInTheDocument(); - expect(screen.getByText(/Nome é obrigatório/i)).toBeInTheDocument(); + expect(screen.getByText(/Name is required/i)).toBeInTheDocument(); }); it('shows validation error when arrival time is negative', async () => { const user = userEvent.setup(); render( {}} />); - const nameInput = screen.getByLabelText('Nome do processo'); + const nameInput = screen.getByLabelText('Process name'); await user.type(nameInput, 'P1'); - const arrivalInput = screen.getByLabelText('Tempo de chegada'); + const arrivalInput = screen.getByLabelText('Arrival time'); // fireEvent.change used to reliably set a negative number bypassing HTML min attribute fireEvent.change(arrivalInput, { target: { value: '-1' } }); - const submitBtn = screen.getByRole('button', { name: /Criar/i }); + const submitBtn = screen.getByRole('button', { name: /Create/i }); await user.click(submitBtn); - expect(screen.getByText(/Arrival Time deve ser ≥ 0/i)).toBeInTheDocument(); + expect(screen.getByText(/Arrival Time must be ≥ 0/i)).toBeInTheDocument(); }); it('shows validation error for name longer than 8 chars', async () => { const user = userEvent.setup(); render( {}} />); - const nameInput = screen.getByLabelText('Nome do processo'); + const nameInput = screen.getByLabelText('Process name'); // Bypass the HTML maxLength attribute via fireEvent to test the JS validation fireEvent.change(nameInput, { target: { value: 'ProcessXXLong' } }); - await user.click(screen.getByRole('button', { name: /Criar/i })); - expect(screen.getByText(/Nome deve ter no máximo 8 caracteres/i)).toBeInTheDocument(); + await user.click(screen.getByRole('button', { name: /Create/i })); + expect(screen.getByText(/Name must be at most 8 characters/i)).toBeInTheDocument(); }); it('adds a new burst with alternating type when clicking + button', async () => { const user = userEvent.setup(); render( {}} />); - const addBurstBtn = screen.getByLabelText('Adicionar burst'); + const addBurstBtn = screen.getByLabelText('Add burst'); await user.click(addBurstBtn); // After one CPU burst at start, clicking + adds IO burst // getAllByText with exact matches for the type labels @@ -80,9 +80,9 @@ describe('ProcessForm', () => { const user = userEvent.setup(); const onClose = vi.fn(); render(); - const nameInput = screen.getByLabelText('Nome do processo'); + const nameInput = screen.getByLabelText('Process name'); await user.type(nameInput, 'P1'); - const submitBtn = screen.getByRole('button', { name: /Criar/i }); + const submitBtn = screen.getByRole('button', { name: /Create/i }); await user.click(submitBtn); expect(onClose).toHaveBeenCalledOnce(); }); @@ -90,9 +90,9 @@ describe('ProcessForm', () => { it('adds the process to the store after successful submission', async () => { const user = userEvent.setup(); render( {}} />); - const nameInput = screen.getByLabelText('Nome do processo'); + const nameInput = screen.getByLabelText('Process name'); await user.type(nameInput, 'Test1'); - await user.click(screen.getByRole('button', { name: /Criar/i })); + await user.click(screen.getByRole('button', { name: /Create/i })); const processes = useProcessStore.getState().processes; expect(processes).toHaveLength(1); expect(processes[0]?.name).toBe('Test1'); diff --git a/src/components/__tests__/SchedulerConfig.test.tsx b/src/components/__tests__/SchedulerConfig.test.tsx index 5f278ee..f2406aa 100644 --- a/src/components/__tests__/SchedulerConfig.test.tsx +++ b/src/components/__tests__/SchedulerConfig.test.tsx @@ -26,7 +26,7 @@ beforeEach(() => { describe('SchedulerConfig', () => { it('always shows Context Switch field regardless of algorithm', () => { render(); - expect(screen.getByLabelText('Tempo de context switch')).toBeInTheDocument(); + expect(screen.getByLabelText('Context switch time')).toBeInTheDocument(); }); it('always shows read-only preemptive badge', () => { @@ -34,23 +34,23 @@ describe('SchedulerConfig', () => { expect(screen.getByTestId('preemptive-badge')).toBeInTheDocument(); }); - it('badge shows "Não-preemptivo" for FCFS', () => { + it('badge shows "Non-preemptive" for FCFS', () => { render(); - expect(screen.getByTestId('preemptive-badge')).toHaveTextContent('Não-preemptivo'); + expect(screen.getByTestId('preemptive-badge')).toHaveTextContent('Non-preemptive'); }); - it('badge shows "Preemptivo" for SJF_P (SRTF)', () => { + it('badge shows "Preemptive" for SJF_P (SRTF)', () => { setAlgorithm('SJF_P'); render(); - expect(screen.getByTestId('preemptive-badge')).toHaveTextContent('Preemptivo'); + expect(screen.getByTestId('preemptive-badge')).toHaveTextContent('Preemptive'); }); - it('badge shows "Não-preemptivo" for SJF_NP (preemptive toggle no longer exists)', () => { + it('badge shows "Non-preemptive" for SJF_NP (preemptive toggle no longer exists)', () => { setAlgorithm('SJF_NP'); render(); - expect(screen.getByTestId('preemptive-badge')).toHaveTextContent('Não-preemptivo'); + expect(screen.getByTestId('preemptive-badge')).toHaveTextContent('Non-preemptive'); // Confirm the old interactive preemptive switch is gone - expect(screen.queryByRole('switch', { name: /Preemptivo/i })).not.toBeInTheDocument(); + expect(screen.queryByRole('switch', { name: /Preemptive/i })).not.toBeInTheDocument(); }); it('does NOT show Quantum field for FCFS', () => { @@ -62,7 +62,7 @@ describe('SchedulerConfig', () => { setAlgorithm('RR'); render(); expect(screen.getByTestId('quantum-field')).toBeInTheDocument(); - expect(screen.getByLabelText('Quantum do Round Robin')).toBeInTheDocument(); + expect(screen.getByLabelText('Round Robin quantum')).toBeInTheDocument(); }); it('shows MLQ queue config panel when algorithm is MULTILEVEL', () => { @@ -97,13 +97,13 @@ describe('SchedulerConfig', () => { const agingToggle = screen.getByRole('switch', { name: /Aging/i }); await user.click(agingToggle); expect(screen.getByTestId('aging-interval-field')).toBeInTheDocument(); - expect(screen.getByLabelText('Intervalo de aging')).toBeInTheDocument(); + expect(screen.getByLabelText('Aging interval')).toBeInTheDocument(); }); it('updates the store when Quantum field is changed', () => { setAlgorithm('RR'); render(); - const quantumInput = screen.getByLabelText('Quantum do Round Robin'); + const quantumInput = screen.getByLabelText('Round Robin quantum'); fireEvent.change(quantumInput, { target: { value: '5' } }); expect(useProcessStore.getState().config.quantum).toBe(5); }); diff --git a/src/core/__tests__/engine.test.ts b/src/core/__tests__/engine.test.ts index f35625a..7319184 100644 --- a/src/core/__tests__/engine.test.ts +++ b/src/core/__tests__/engine.test.ts @@ -236,11 +236,11 @@ describe("SimulationEngine — ciclo de vida", () => { }); // ============================================================ -// SimulationEngine — chegada de processos +// SimulationEngine — process arrival // Tests: late arrivals, idle ticks while waiting for process // ============================================================ -describe("SimulationEngine — chegada de processos", () => { +describe("SimulationEngine — process arrival", () => { it("process arriving after simulation starts is correctly scheduled", () => { const engine = new SimulationEngine( [ diff --git a/src/core/presets.ts b/src/core/presets.ts index 7e23d61..8293186 100644 --- a/src/core/presets.ts +++ b/src/core/presets.ts @@ -107,7 +107,7 @@ export const presets: Preset[] = [ }, { name: "context_switch_demo", - description: "3 processos FCFS com 2 ticks de overhead — veja as células vermelhas de Context Switch", + description: "3 FCFS processes with 2 ticks of overhead — see the red Context Switch cells", processes: [ { pid: 1, id: "p1", name: "P1", arrivalTime: 0, priority: 5, color: "#4FC3F7", bursts: [{ type: "cpu", duration: 3 }] }, { pid: 2, id: "p2", name: "P2", arrivalTime: 0, priority: 5, color: "#81C784", bursts: [{ type: "cpu", duration: 3 }] }, diff --git a/src/hooks/useExport.ts b/src/hooks/useExport.ts index a795788..3910b33 100644 --- a/src/hooks/useExport.ts +++ b/src/hooks/useExport.ts @@ -18,7 +18,9 @@ function downloadBlob(content: string, filename: string, mimeType: string) { export function useExport() { const exportCSV = (metrics: ProcessMetrics[], processMap: ProcessMap) => { const headers = [ - "Processo", + "PID", + "Process", + "Priority", "Arrival", "Start", "Finish", @@ -32,9 +34,14 @@ export function useExport() { ]; const rows = metrics.map((m) => { - const name = processMap[m.processId]?.name ?? m.processId; + const proc = processMap[m.processId]; + const pid = proc?.pid ?? ""; + const name = proc?.name ?? m.processId; + const priority = proc?.priority ?? ""; return [ + pid, name, + priority, m.arrivalTime, m.startTick, m.finishTick,
ProcessoProcess Arrival Start Finish