A sophisticated operating system simulator built with .NET 8 that demonstrates core OS concepts including process scheduling, file system management, memory management, and inter-process communication.
- Features
- Architecture
- Getting Started
- Usage
- Project Structure
- Testing
- Core Components
- Design Patterns
- Contributing
- Documentation
- License
- Authors
- Priority-based Scheduling: Max-heap priority queue implementation for efficient process scheduling
- Process Hierarchy: Parent-child process relationships with process tree structure
- Multi-state Processes: Support for New, Ready, Running, Waiting, and Terminated states
- Dynamic Priority Adjustment: Runtime priority recalculation based on execution history
- File-dependent Processes: Processes can wait for file availability before execution
- Hierarchical Structure: Unix-like directory tree with root-based navigation
- File Operations: Create, delete, move, copy, and rename files and directories
- Recursive Search: Deep file system traversal and pattern matching
- Path Validation: Comprehensive validation for paths and filenames
- Size Tracking: Automatic directory and file size calculation
- Metadata Management: Creation time, modification time, and file properties
- Dual Logging System: Separate loggers for process execution and file system operations
- Named Pipe Communication: Real-time log streaming to external monitoring tools
- Cycle-based Logging: Detailed execution cycle summaries with process states
- File System Snapshots: Complete file tree logging at shutdown
- Interactive REPL: Read-Eval-Print Loop for real-time system interaction
- Command Parser: Flexible command syntax with parameter validation
- Error Handling: Comprehensive error messages and validation feedback
- Help System: Built-in command documentation and usage examples
???????????????????????????????????????????????????????????????
? DS-OS Architecture ?
???????????????????????????????????????????????????????????????
? ?
? ???????????????? ???????????????? ???????????????? ?
? ? Command ? ? Process ? ? File ? ?
? ? Handler ? ? Executor ? ? Manager ? ?
? ???????????????? ???????????????? ???????????????? ?
? ? ? ? ?
? ? ? ? ?
? ?????????????????????????????????????????????????????? ?
? ? Database Manager (Core State) ? ?
? ? ?????????????? ???????????????? ?????????????? ? ?
? ? ? Process ? ? Ready ? ? Waiting ? ? ?
? ? ? Tree ? ? Queue ? ? Queue ? ? ?
? ? ?????????????? ???????????????? ?????????????? ? ?
? ??????????????????????????????????????????????????????? ?
? ? ?
? ?????????????????? ?
? ? Logger System ? ?
? ?????????????????? ?
???????????????????????????????????????????????????????????????
- Quantum-based execution cycles
- Time-out handling and context switching
- File dependency checking
- State transition management
- Centralized process and queue management
- Thread-safe operations with semaphores
- Ready queue with configurable size limits
- Dual waiting queues (file and ready-limit)
- Tree-based directory structure
- Lock-based thread safety
- Recursive operations support
- Efficient path resolution
- Process state updates
- File availability monitoring
- Queue management coordination
- Priority recalculation
- .NET 8.0 SDK or later
- A code editor (Visual Studio 2022, VS Code, or Rider recommended)
- Windows, macOS, or Linux operating system
-
Clone the repository
git clone https://github.com/ahk1384/DS-OS.git cd DS-OS -
Restore dependencies
dotnet restore
-
Build the project
dotnet build
cd DS-OS
dotnet runYou should see:
=== DS-OS Starting ===
Loading system settings...
Starting process executor...
=== DS-OS Ready ===
Operating System Simulator is now running.
Type commands to interact with the system.
DS-OS>
# Create a directory
DIRECTORYCREATE(path:/,name:home)
DIRECTORYCREATE(path:/home,name:user1)
# Create a file
FILECREATE(path:/home,name:test.txt)
FILECREATE(path:/home,name:data.bin,size:1024)
# Delete a file or directory
FILEDELETE(path:/home/test.txt)# Create a process without file dependency
PROCESSCREATE(pid:1,parent:0,priority:5,burst:100)
# Create a process with file dependency
PROCESSCREATE(pid:2,parent:0,priority:3,burst:50,filepath:/home/data.txt)
# Delete a process
PROCESSDELETE(pid:1)# Start the process executor
start
# Display help
help
# Shutdown the system
SHUTDOWN()DS-OS> DIRECTORYCREATE(path:/,name:projects)
Directory 'projects' created successfully in '/'
Full path: /projects
DS-OS> DIRECTORYCREATE(path:/projects,name:app1)
Directory 'app1' created successfully in '/projects'
DS-OS> FILECREATE(path:/projects/app1,name:main.cs,size:2048)
File 'main.cs' created successfully in '/projects/app1'
DS-OS> FILECREATE(path:/projects/app1,name:config.json,size:512)
File 'config.json' created successfully in '/projects/app1'DS-OS> start
Process executor started
DS-OS> PROCESSCREATE(pid:10,parent:0,priority:8,burst:50)
Process 10 created successfully
DS-OS> PROCESSCREATE(pid:11,parent:0,priority:5,burst:75,filepath:/projects/app1/main.cs)
Process 11 created successfullyDS-OS> PROCESSCREATE(pid:20,parent:0,priority:7,burst:100,filepath:/data/input.txt)
Process 20 created successfully
# Process will wait if file doesn't exist
DS-OS> DIRECTORYCREATE(path:/,name:data)
DS-OS> FILECREATE(path:/data,name:input.txt,size:1024)
# Process 20 will now become ready and executeDS-OS/
??? DS-OS/ # Main application project
? ??? DataBaseManager/ # Process and queue management
? ? ??? DataBaseManager.cs
? ? ??? IDataBaseManager.cs
? ??? DataStructer/ # Core data structures
? ? ??? FileTree/
? ? ? ??? FileNode.cs # File system node
? ? ? ??? FileTree.cs # File system tree
? ? ??? PCB.cs # Process Control Block
? ? ??? ProcessTree.cs # Process hierarchy
? ? ??? ReadyPriorityQueue.cs # Priority-based queue
? ? ??? WaitingQueue.cs # Waiting processes
? ? ??? State.cs # Process states
? ? ??? WaitReason.cs # Wait reasons
? ??? Engine/ # Execution engine
? ? ??? CommandHandler/ # Command processing
? ? ? ??? CommandHandler.cs
? ? ? ??? ICommandHandler.cs
? ? ? ??? BaseClass/
? ? ? ??? Command.cs
? ? ? ??? CommandType.cs
? ? ??? ProcessExecutor/ # Process execution
? ? ? ??? ProcessExecutor.cs
? ? ? ??? IProcessExecutor.cs
? ? ??? ProcessManager/ # Process state management
? ? ??? ProcessManager.cs
? ? ??? IProcessManager.cs
? ??? FileManager/ # File system operations
? ? ??? FileManager.cs
? ? ??? IFileManager.cs
? ??? Logger/ # Logging system
? ? ??? ProcessLogger.cs # Process execution logs
? ? ??? FileLogger.cs # File system logs
? ? ??? ILogger.cs
? ? ??? LongType.cs # Log message types
? ??? Parser/ # Command parsing
? ? ??? QueryParser.cs
? ? ??? IQueryParser.cs
? ??? Exceptions/ # Custom exceptions
? ??? ConfigureSettings.cs # Configuration loader
? ??? Program.cs # Entry point
??? DS-OS-Test/ # Test project
? ??? FileManagerTests.cs # File manager tests (46)
? ??? LoggerTests.cs # Logger tests (13)
? ??? IntegrationTests.cs # Integration tests
? ??? FileTreeTests.cs # File tree tests
? ??? FileNodeTests.cs # File node tests
? ??? PcbTests.cs # PCB tests
? ??? ReadyPriorityQueueTests.cs # Queue tests
? ??? CommandTests.cs # Command tests
? ??? TESTING_SUMMARY.md # Test documentation
??? Logs/ # External logging service
??? README.md # This file
The project includes a comprehensive test suite with 143 tests covering all major components.
# Run all tests
dotnet test
# Run specific test class
dotnet test --filter "FullyQualifiedName~FileManagerTests"
# Run with detailed output
dotnet test --logger "console;verbosity=detailed"| Component | Tests | Coverage |
|---|---|---|
| FileManager | 46 | 95% |
| Logger | 13 | 90% |
| FileTree | 25 | 100% |
| FileNode | 20 | 100% |
| PCB | 15 | 100% |
| Priority Queue | 12 | 100% |
| Integration | 12 | 85% |
Test summary: total: 143; failed: 0; succeeded: 141; skipped: 2
Success Rate: 100%
See TESTING_SUMMARY.md for detailed test documentation.
public class Pcb
{
public int Pid { get; }
public string Name { get; }
public int Priority { get; set; }
public int RemaningTime { get; set; }
public State State { get; set; }
public bool NeedsFile { get; set; }
public string FilePath { get; set; }
public WaitReason WaitReason { get; set; }
public Pcb Parent { get; set; }
public Dictionary<int, Pcb> Children { get; set; }
}public class FileNode
{
public string Name { get; set; }
public FileNode? Parent { get; set; }
public bool IsFile { get; set; }
public bool IsDirectory => !IsFile;
public Dictionary<string, FileNode> Children { get; set; }
public string FullPath => GetFullPath();
public DateTime CreatedTime { get; set; }
public DateTime ModifiedTime { get; set; }
public long Size { get; set; }
}public class ReadyPriorityQueue
{
public int Count { get; }
public int MaxSize { get; set; }
public bool IsEmpty { get; }
public bool Enqueue(Pcb process);
public Pcb Dequeue();
public Pcb Peek();
public bool IsFull();
}IDataBaseManagerabstracts data access- Centralized state management
- Easy to test and mock
- Command handlers implement different strategies
- Extensible command system
- Clean separation of concerns
Pcb.Create()factory methodsFileNode.CreateFile(),FileNode.CreateDirectory()- Consistent object creation
- Logger system observes process execution
- File manager notifies process manager of file changes
- Single instance of core managers
- Dependency injection for testability
- Base command processing flow
- Customizable command execution steps
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Commit your changes
git commit -m 'Add some amazing feature' - Push to the branch
git push origin feature/amazing-feature
- Open a Pull Request
- Follow C# coding conventions
- Write unit tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting PR
- Use meaningful commit messages
- ?? Bug fixes
- ? New features
- ?? Documentation improvements
- ?? Additional test coverage
- ?? UI/UX enhancements
- ?? Internationalization
{
"readyLimit": 10,
"quantumSize": 5,
"executionPerCycle": 3,
"Prf": 2
}- readyLimit: Maximum processes in ready queue
- quantumSize: Time quantum for each process (in time units)
- executionPerCycle: Number of processes to execute per cycle
- Prf: Priority recalculation factor
| State | Description |
|---|---|
New |
Process just created |
Ready |
Process ready to execute |
Running |
Process currently executing |
Waiting |
Process waiting for resource |
Terminated |
Process completed |
| Reason | Description |
|---|---|
File |
Waiting for file to be created |
ReadyLimit |
Ready queue is full |
IO |
Waiting for I/O operation |
This project is licensed under the MIT License - see the LICENSE file for details.
- Amir Hossein Karimi - Initial work - @ahk1384
- Inspired by modern operating system concepts
- Built with .NET 8 and C# 12
- Thanks to all contributors and testers
- GitHub: @ahk1384
- Project Link: https://github.com/ahk1384/DS-OS
- Multi-threading support for parallel process execution
- Memory management simulation (paging, segmentation)
- Deadlock detection and prevention
- GUI interface for visualization
- Network simulation for distributed processes
- Performance metrics and statistics dashboard
- Docker containerization
- API endpoints for external control
- Disk scheduling algorithms
- Virtual memory management
? Star this repository if you find it helpful!
Made with ?? by Amir Hossein Khazaei