An educational operating system developed as part of an Operating Systems course. This project implements core OS components including memory management, process scheduling, system calls, and concurrency primitives.
Top 10 placement across all projects - Successfully implemented and passed all test cases for the assigned components.
FOS (FCIS Operating System) is a 32-bit x86 operating system built from scratch. The project covers fundamental OS concepts including:
- Boot Process: Custom bootloader that loads the kernel from disk
- Memory Management: Virtual memory, paging, heap allocation, and page replacement algorithms
- Process Management: User environments, context switching, and scheduling
- System Calls: Interface between user programs and kernel
- Concurrency: Semaphores, locks, and inter-process communication
- I/O Management: Console, keyboard, and disk interfaces
The system uses a sophisticated virtual memory layout:
- Kernel Space (0xF0000000+): Kernel code, data, and heap
- User Space (0x00000000-0xEF800000): User programs, stack, and heap
- Shared Memory: Inter-process shared memory regions
- Page Tables: Virtual-to-physical address translation
FOS/
├── boot/ # Bootloader (boot.S, main.c)
├── kern/ # Kernel implementation
│ ├── cpu/ # CPU management, scheduling
│ ├── mem/ # Memory management
│ ├── proc/ # Process/user environment management
│ ├── trap/ # Interrupts, exceptions, system calls
│ ├── conc/ # Concurrency primitives
│ ├── cons/ # Console I/O
│ ├── cmd/ # Command prompt
│ └── disk/ # Disk/pagefile management
├── lib/ # User-space library functions
├── user/ # User programs and test cases
└── inc/ # Header files and definitions
All functions marked with TODO: comments were successfully implemented and passed test cases. The implementation includes:
- System call parameter validation
- System call dispatch mechanism
- User-space system call wrappers
initialize_dynamic_allocator()- Initialize the allocatorset_block_data()- Set block metadataalloc_block_FF()- First-fit allocation algorithmalloc_block_BF()- Best-fit allocation (bonus)
initialize_kheap_dynamic_allocator()- Initialize kernel heapsbrk()- Adjust heap sizekmalloc()- Kernel memory allocationkfree()- Kernel memory deallocationkheap_physical_address()- Physical address translationkheap_virtual_address()- Virtual address translationkrealloc()- Reallocation (bonus)
malloc()- User-space memory allocationfree()- User-space memory deallocationsys_sbrk()- System call for heap growthallocate_user_mem()- Kernel-side allocationfree_user_mem()- Kernel-side deallocation- O(1) free implementation (bonus)
smalloc()- Shared memory allocationsget()- Get shared memory objectsfree()- Free shared memory (bonus)create_frames_storage()- Frame storage managementcreate_share()- Create shared objectget_share()- Retrieve shared objectcreateSharedObject()- Kernel-side creationgetSharedObject()- Kernel-side retrievalfreeSharedObject()- Kernel-side deallocation (bonus)
- Invalid pointer detection
- Page placement algorithm
- Page fault handling
- Create new working set elements
- Track page access patterns
create_user_kern_stack()- Create kernel stack for user processinitialize_uheap_dynamic_allocator()- Initialize user heap
create_semaphore()- Create semaphoreget_semaphore()- Get semaphore by IDwait_semaphore()- Wait/P operationsignal_semaphore()- Signal/V operation
- Spinlocks: Low-level synchronization
- Sleep Locks: Blocking locks for long operations
acquire_sleeplock()- Acquire sleep lockrelease_sleeplock()- Release sleep lock
sleep()- Put process to sleepwakeup_one()- Wake single waiting processwakeup_all()- Wake all waiting processes
- Priority-based Round-Robin scheduling
sched_init_PRIRR()- Initialize priority schedulerfos_scheduler_PRIRR()- Main scheduling algorithmclock_interrupt_handler()- Timer interrupt handlingenv_set_priority()- Set process prioritysched_set_starv_thresh()- Set starvation threshold
process_command()- Command parsing and execution- Interactive kernel shell
The project includes comprehensive test suites covering:
- Memory allocation and deallocation
- Heap placement strategies (First-fit, Best-fit)
- Page replacement algorithms
- Shared memory operations
- Semaphore operations
- Process scheduling
- System call functionality
- Protection and security checks
Test programs are located in the user/ directory with naming convention tst_*.c.
- i386-elf cross-compiler toolchain
- Bochs emulator
- Make (GNU Make)
# Build the entire system
make
# Run in Bochs emulator
make bochs
# Or use the provided batch file (Windows)
FOS_Developer_Console.bat- Kernel image:
obj/kern/bochs.img - User programs:
obj/user/*.o
FOS/
├── boot/ # Bootloader code
│ ├── boot.S # Assembly boot code
│ └── main.c # C boot code
├── kern/ # Kernel source
│ ├── cpu/ # CPU and scheduling
│ ├── mem/ # Memory management
│ ├── proc/ # Process management
│ ├── trap/ # Interrupts and syscalls
│ ├── conc/ # Concurrency
│ ├── cons/ # Console
│ ├── cmd/ # Command prompt
│ └── disk/ # Disk management
├── lib/ # User-space library
├── user/ # User programs and tests
├── inc/ # Header files
├── conf/ # Build configuration
└── GNUmakefile # Main build file
- First-Fit: Allocate from first suitable block
- Best-Fit: Allocate from smallest suitable block (bonus)
- FIFO: First-In-First-Out
- LRU: Least Recently Used (approximations)
- N-Chance Clock: Clock algorithm variant
- Priority Round-Robin: Priority-based with time slicing
- Starvation prevention mechanisms
This project was developed as part of an Operating Systems course, implementing:
- MS1 (Milestone 1): System calls, dynamic allocator, concurrency primitives
- MS2 (Milestone 2): Memory management, heap, shared memory, fault handling
- MS3 (Milestone 3): Scheduling, semaphores, priority management
- ✅ All TODO functions implemented and tested
- ✅ Comprehensive test coverage
- ✅ Bonus features implemented (Best-fit, O(1) free, shared memory deallocation)
- ✅ Clean, well-documented code
- ✅ Top 10 project ranking
- The system runs in 32-bit protected mode
- Uses x86 architecture with paging enabled
- Supports multiple user environments (processes)
- Implements virtual memory with demand paging
- Includes page replacement algorithms for memory management
This project was developed as part of an educational Operating Systems course. All functions marked with TODO: comments were implemented by the development team and successfully passed all test cases.
See inc/COPYRIGHT and kern/COPYRIGHT for copyright information.
Note: This is an educational project. The codebase includes both provided framework code and student implementations. All functions we've successfully implemented are marked with TODO: comments in the source code.