- Scheduler loop
- Round Robin queue
display_info()functionSIGINThandler for Scheduler
- Shared memory and semaphore setup & cleanup
- Shell loop
SIGCHLDhandler for Shelldummy_main.h
Both members contributed to:
- Error handling
- Bug fixing
-
The codebase is well documented using:
- Comments
- Appropriate variable names
- Meaningful function names
- Runs an infinite loop to continuously accept user input.
- Terminates explicitly when the
exitcommand is entered.
- Initializes shared memory for maintaining the process table.
-
Initializes semaphores for:
- Mutual exclusion
- Safe concurrent access while reading/writing shared memory
- Creates a separate scheduler process before starting the shell loop.
- Updates the process table whenever a child process finishes execution.
submit <executable>- Creates a child process for the executable.
- Submits the process to the scheduler for scheduling.
- Sends a termination signal to the scheduler.
- Waits for the scheduler process to terminate.
- Prints required execution details.
- Cleans up resources and exits gracefully.
- Continuously reads the process table in an infinite scheduling loop.
- Picks
NCPUprocesses for execution forTSLICEmilliseconds.
-
Pop
NCPUprocesses from the queue. -
Signal selected processes to execute.
-
Update:
- Time spent on CPU
- Time spent off CPU
-
Sleep for
TSLICEmilliseconds. -
Signal running processes to stop.
- Processes are scheduled in a Round Robin fashion.
- Ensures fair CPU allocation among submitted processes.
- Scheduler terminates immediately.
- Scheduler continues executing remaining processes.
- Terminates only after all processes complete execution.
- Helps manage graceful termination of the scheduler.
Before beginning the scheduling loop:
- Shared memory is initialized.
- Semaphores are initialized.
- Contains boilerplate code provided in the assignment.
The following line was added:
raise(SIGSTOP);- Ensures each process blocks immediately after
exec()execution. - Prevents processes from executing automatically.
- Makes the process wait for:
SIGCONTfrom the scheduler before execution begins.
User submits executable
↓
SimpleShell
↓
Creates child process
↓
Process added to shared process table
↓
SimpleScheduler
↓
Selects NCPU processes
↓
Sends SIGCONT
↓
Processes execute for TSLICE
↓
Sends stop signal
↓
Round Robin continues
The following data is stored in shared memory:
- Process table
- Scheduling information
- CPU timing statistics
Used to:
- Prevent race conditions
- Ensure safe concurrent access
- Synchronize Shell and Scheduler operations
| Signal | Purpose |
|---|---|
SIGSTOP |
Pause newly created processes |
SIGCONT |
Resume scheduled processes |
SIGCHLD |
Detect child process completion |
SIGINT |
Graceful scheduler termination |
fork()exec()wait()signal()raise()kill()shm_open()mmap()sem_init()sem_wait()sem_post()
- Round Robin process scheduling
- Configurable CPU time slicing
- Shared memory based process table
- Semaphore synchronization
- Multi-process coordination using signals
- Graceful scheduler termination
- Execution tracking and statistics
-
Processes do not begin execution immediately after
exec(). -
Scheduler-controlled execution is achieved using:
SIGSTOPSIGCONT
-
Shared memory enables communication between:
- Shell
- Scheduler
-
Semaphore synchronization ensures consistency of the shared process table.
-
The scheduler guarantees completion of submitted processes before termination.