Skip to content

Commit fcfc53a

Browse files
Merge branch 'main' into AIC
2 parents 9884a03 + b85d4d9 commit fcfc53a

63 files changed

Lines changed: 3219 additions & 314 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

β€Ž.github/workflows/syntax-check.ymlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Python Syntax Check
33
on:
44
pull_request:
55
branches:
6-
- main # or your default branch
6+
- main # default branch
77

88
jobs:
99
syntax-check:

β€ŽCloudKernel/ARCHITECTURE.mdβ€Ž

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# CloudKernel Architecture
2+
3+
## Purpose
4+
5+
CloudKernel models a cloud-hypervisor execution cycle with Java concurrency primitives while exposing runtime behavior through a real-time Swing dashboard.
6+
7+
## Layers
8+
9+
- Entry: Main.java
10+
- Configuration: config.ConfigLoader
11+
- Concurrency Core: core.BootManager, core.ClockSynchronizer
12+
- Runtime Entities: entities.VirtualMachine, entities.ResourceManager, entities.VMState, entities.VMPriority, entities.VMStats
13+
- Observability: utils.GUILogger, utils.StatsCollector
14+
- UI: ui.CloudKernelGUI and component panels
15+
- Shutdown: shutdown.ShutdownManager
16+
17+
## Concurrency Contracts
18+
19+
### BootManager
20+
21+
- Uses CountDownLatch(4).
22+
- Boots disk, RAM, network stack, and CPU scheduler asynchronously.
23+
- Exposes latch for visual countdown.
24+
25+
### ClockSynchronizer
26+
27+
- Uses CyclicBarrier(vmCount).
28+
- Increments global cycle in barrier action.
29+
- Records cycle completion in StatsCollector.
30+
31+
### ResourceManager
32+
33+
- Uses three fair semaphores:
34+
- CPU permits
35+
- Memory permits
36+
- Network permits
37+
- Uses timeout-based tryAcquire for deadlock-resistant resource requests.
38+
- Tracks current holders for UI rendering.
39+
40+
### VirtualMachine
41+
42+
- Executes configured number of cycles.
43+
- Transitions through VMState values.
44+
- Requests CPU, memory, network resources sequentially.
45+
- Synchronizes on cyclic barrier each cycle.
46+
47+
## UI Composition
48+
49+
CloudKernelGUI builds the dashboard from modular components:
50+
51+
- VMCard
52+
- ResourceMonitorPanel
53+
- BarrierPanel
54+
- LogPanel
55+
- StatsBar
56+
- ControlPanel
57+
- DashboardUpdater
58+
59+
DashboardUpdater centralizes UI refresh operations and dispatches thread-crossing updates via SwingUtilities.invokeLater.
60+
61+
## Data And Events
62+
63+
- GUILogger writes every event to terminal and broadcasts to GUI listeners.
64+
- CloudKernelGUI parses selected log patterns to drive visual state changes.
65+
- StatsCollector aggregates per-VM and system-wide counters for the stats bar and summary output.
66+
67+
## Runtime Flow
68+
69+
1. Main launches CloudKernelGUI on the Swing event dispatch thread.
70+
2. GUI initializes managers and registers listeners.
71+
3. User starts simulation through ControlPanel.
72+
4. BootManager performs subsystem initialization.
73+
5. VirtualMachine threads execute cycles with resource access and barrier sync.
74+
6. DashboardUpdater continuously refreshes resources, VM cards, barrier state, and stats.
75+
7. ShutdownManager prints graceful summary on termination.
76+
77+
<img src="img/screen.png">

β€ŽCloudKernel/README.mdβ€Ž

Lines changed: 104 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -1,181 +1,129 @@
1-
# CloudKernel β˜οΈβš™οΈ
1+
# CloudKernel
22

3-
## Overview
3+
CloudKernel is a Java concurrency simulator with a professional Swing dashboard that visualizes hypervisor-like VM scheduling, shared resource contention, and synchronization.
44

5-
**CloudKernel** is a small Java-based simulation created for our **Operating Systems Lab**.
6-
The purpose of this project is to show how a hypervisor-like system can manage multiple **Virtual Machines (VMs)** while coordinating shared resources.
5+
## πŸ“‹ Project Information
76

8-
Instead of building a real operating system, this project focuses on demonstrating **important OS concepts** like synchronization, resource sharing, and concurrent execution using Java threads.
9-
10-
The program simulates a system where several virtual machines start after the system boots, run tasks together, and share limited network resources.
11-
12-
---
13-
14-
## πŸŽ“ Academic Information
15-
16-
**Course:** Operating Systems Lab
17-
**Semester:** 4th Semester
18-
19-
**Submitted to:**
20-
Mam Amara Nadeem
21-
22-
**Submitted by:**
23-
24-
- **Moavia Amir** (2k24_BSAI_72)
25-
- **Ali Raza** (2k24_BSAI_44)
26-
- **Muhammad Arslan Nasir** (2k24_BSAI_26)
27-
28-
**Submission Date:**
29-
March 03, 2026
30-
31-
---
32-
33-
## 🎯 Project Goals
34-
35-
This project was designed to help understand how operating systems manage:
36-
37-
- System boot coordination
38-
- Thread synchronization
39-
- Limited resource sharing
40-
- Parallel execution of processes
41-
42-
All these ideas are implemented using **Java concurrency utilities**.
43-
44-
---
45-
46-
## βš™οΈ Key Concepts Used
47-
48-
### 1. System Boot Coordination
49-
50-
Before any virtual machine starts running, the system must finish its boot process.
51-
52-
We simulate this using **CountDownLatch**.
53-
It ensures that resources like **Disk and RAM** are ready before the virtual machines begin execution.
7+
| Field | Details |
8+
|-------|---------|
9+
| **Subject** | Operating Systems |
10+
| **Semester** | 4th Semester β€” BSAI 2k24 |
11+
| **Institute** | NFC Institute of Engineering & Technology, Multan |
12+
| **Department** | Artificial Intelligence |
13+
| **Submitted To** | Mam Amara Nadeem β€” [ammara.visiting@nfciet.edu.pk](mailto:ammara.visiting@nfciet.edu.pk) |
14+
| **Submission Date** | March 03, 2026 |
5415

5516
---
5617

57-
### 2. VM Cycle Synchronization
18+
## πŸ‘₯ Team Members
19+
20+
| Name | Roll Number | Email |
21+
|------|-------------|-------|
22+
| Muawiya Amir | 2k24_BSAI_72 | [2k24bsai72@undergrad.nfciet.edu.pk](mailto:2k24bsai72@undergrad.nfciet.edu.pk) |
23+
| Ali Raza | 2k24_BSAI_44 | [2k24bsai44@undergrad.nfciet.edu.pk](mailto:2k24bsai44@undergrad.nfciet.edu.pk) |
24+
| Muhammad Arslan Nasir | 2k24_BSAI_26 | [2k24bsai26@undergrad.nfciet.edu.pk](mailto:2k24bsai26@undergrad.nfciet.edu.pk) |
25+
## Highlights
26+
27+
- Dark-theme dashboard: Cloud hypervisor monitor layout.
28+
- Boot orchestration with CountDownLatch.
29+
- VM cycle synchronization with CyclicBarrier.
30+
- Shared CPU, memory, and network resources with fair semaphores and timeout handling.
31+
- Color-coded live logs streamed to terminal and GUI simultaneously.
32+
- Live stats for cycles, operations, contentions, timeouts, and uptime.
33+
- Configurable behavior through config.properties.
34+
35+
<img src ="img/banner.png">
36+
## Final Package Structure
37+
38+
```text
39+
CloudKernel/
40+
src/
41+
Main.java
42+
config/
43+
ConfigLoader.java
44+
core/
45+
BootManager.java
46+
ClockSynchronizer.java
47+
entities/
48+
ResourceManager.java
49+
VirtualMachine.java
50+
VMPriority.java
51+
VMState.java
52+
VMStats.java
53+
shutdown/
54+
ShutdownManager.java
55+
ui/
56+
BarrierPanel.java
57+
CloudKernelGUI.java
58+
ControlPanel.java
59+
DashboardUpdater.java
60+
LogPanel.java
61+
ResourceMonitorPanel.java
62+
StatsBar.java
63+
VMCard.java
64+
utils/
65+
GUILogger.java
66+
StatsCollector.java
67+
config.properties
68+
ARCHITECTURE.md
69+
doc/
70+
PROJECT_PROPOSAL.md
71+
PROJECT_Report.md
72+
Project_presentation.ppt
5873
59-
Each virtual machine performs its work in cycles.
60-
To keep them synchronized, we use **CyclicBarrier**.
61-
62-
This means all VMs must finish a cycle before the next one begins.
63-
64-
---
6574
66-
### 3. Limited Network Access
67-
68-
In real systems, hardware resources are limited.
69-
In this simulation, only **two VMs can use the network at the same time**.
70-
71-
This is managed using a **Semaphore**, which controls access to the shared network ports.
72-
73-
---
74-
75-
## 🧩 Project Structure
76-
```
77-
CloudKernel
78-
β”‚
79-
β”œβ”€β”€ src
80-
β”‚ β”‚
81-
β”‚ β”œβ”€β”€ Main.java
82-
β”‚ β”‚
83-
β”‚ β”œβ”€β”€ core
84-
β”‚ β”‚ β”œβ”€β”€ BootManager.java
85-
β”‚ β”‚ β”œβ”€β”€ ClockSynchronizer.java
86-
β”‚ β”‚ └── NetworkPortManager.java
87-
β”‚ β”‚
88-
β”‚ β”œβ”€β”€ entities
89-
β”‚ β”‚ └── VirtualMachine.java
90-
β”‚ β”‚
91-
β”‚ └── utils
92-
β”‚ └── Logger.java
93-
β”‚
94-
β”œβ”€β”€ doc
95-
β”‚ └── proposal
96-
β”‚
97-
└── README.md
9875
```
99-
---
10076

101-
## πŸ— System Workflow
77+
## GUI Overview
10278

103-
The program runs in the following order:
79+
Main window sections:
10480

105-
```
106-
System Boot
107-
β”‚
108-
β–Ό
109-
BootManager initializes resources
110-
β”‚
111-
β–Ό
112-
Virtual Machines start (Threads)
113-
β”‚
114-
β–Ό
115-
VMs execute cycles together
116-
β”‚
117-
β–Ό
118-
Network access controlled by Semaphore
119-
β”‚
120-
β–Ό
121-
Logs printed to terminal
122-
```
81+
- Header: title, digital clock, online indicator.
82+
- Boot panel: resource chips and latch countdown.
83+
- VM dashboard: one card per VM with state, priority, progress, and resource indicators.
84+
- Left sidebar: semaphore slot view for CPU, memory, and network.
85+
- Barrier panel: arrival dots and cycle display.
86+
- Right sidebar: color-coded live event log.
87+
- Bottom bars: statistics and controls.
12388

124-
---
89+
## Core Concurrency Model
12590

126-
## ▢️ How to Run the Project
91+
- Boot phase: CountDownLatch initialized to four boot tasks.
92+
- Runtime phase: each VM executes for configured cycles.
93+
- Resource phase: each VM requests CPU, memory, and network permits with timeout.
94+
- Synchronization phase: all VMs rendezvous at a CyclicBarrier before the next cycle.
12795

128-
### 1. Compile the project
96+
## Configuration
12997

130-
```bash
131-
javac -d out -sourcepath src src/Main.java
132-
```
133-
### 2. Run the program
134-
```bash
135-
java -cp out Main
136-
```
137-
## πŸ–₯ Example Output
98+
Edit config.properties before running:
13899

139-
When the program runs, you may see output like:
140-
```
141-
[BOOT] Disk initialized
142-
[BOOT] RAM initialized
143-
[BOOT] System ready
144-
145-
[VM-1] Starting execution
146-
[VM-2] Starting execution
147-
[VM-3] Starting execution
100+
- vm.count
101+
- cycle.count
102+
- semaphore.cpu.permits
103+
- semaphore.memory.permits
104+
- semaphore.network.permits
105+
- task.duration.min
106+
- task.duration.max
107+
- timeout.duration
108+
- gui.enabled
109+
- gui.theme
110+
- gui.font
111+
- logging.level
112+
- stats.enabled
148113

149-
[VM-1] Requesting network access
150-
[VM-2] Requesting network access
114+
## Build And Run
151115

152-
[VM-1] Using network port
153-
[VM-2] Using network port
116+
From CloudKernel root:
154117

155-
[VM-3] Waiting for network port
118+
```powershell
119+
javac -encoding UTF-8 -d bin (Get-ChildItem -Recurse src -Filter *.java | ForEach-Object { $_.FullName })
120+
java -cp "bin;." Main
156121
```
157-
The Logger class keeps the output organized so it is easier to read.
158-
159-
## 🧠 What We Learned
160-
161-
While building this project, we understood how operating systems handle:
162-
163-
+ **Thread** synchronization
164-
165-
+ **Shared** resource management
166-
167-
+ **Parallel** execution
168-
169-
+ **Process** coordination
170-
171-
These concepts are important for understanding how real operating systems and cloud platforms work.
172-
173-
---
174122

175-
## πŸ“Œ Conclusion
123+
## Notes
176124

177-
CloudKernel is a simple educational simulation that demonstrates how a hypervisor-like system can coordinate virtual machines and manage shared resources.
125+
- All UI updates triggered by worker threads are dispatched through SwingUtilities.invokeLater.
126+
- Main.java contains only the GUI entry point.
127+
- Legacy duplicate docs and unused legacy classes were removed to keep one canonical implementation path.
178128

179-
Although it is a simplified model, it provides a clear understanding of synchronization and concurrency in operating systems.
180129

181-
---

β€ŽCloudKernel/bin/Main.classβ€Ž

960 Bytes
Binary file not shown.
4.2 KB
Binary file not shown.
3.33 KB
Binary file not shown.
2.23 KB
Binary file not shown.
4.14 KB
Binary file not shown.
2.03 KB
Binary file not shown.
2.21 KB
Binary file not shown.

0 commit comments

Comments
Β (0)