|
||||||
| General Programming Non language specific, Assembly, Linux/Unix, Mac and anything not covered in other topics. Talk about Programming Theory here. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
thanks jordan and winged panther for your replies...i have a new problem guys...do you have any idea about cpu scheduling algorithms?...just like first come first serve scheduling algorithm, round robin algorithm, etc...well...i need a logic for making a program such algorithms in c...if u have answers or suggestions please submit it...thanks!!....
|
| Sponsored Links |
|
|
|
|||||
|
Are you looking for code or information?
Info: http://tunes.org/~unios/std-sched.html Code:
/*ill throw out some pseudo code added to what i know for First Come First Serve Scheduling Algorithms #include<iostream> #include<queue> #include <string> #include<fstream> using namespace std; int CS=10; struct PCB { int CPUbursts[10]; int IObursts[10]; int waitTime; int completionTime; int arrivalTime; int startTime; int CPUcount; int IOcount; }; int main() { int processesDone=0; int busyTime=0; int CScount=0; int systemClock=0; int n; PCB processes[30]; queue<PCB> rdyQueue; queue<PCB> waitQueue; ifstream inData; string fileName; cout << "Enter the filename: "; cin >> fileName; cout << endl; inData.open(fileName.c_str()); for(int i=0;i<30;i++) { for(int j=0;j<10;j++) { inData>>processes[i].CPUbursts[j]; inData>>processes[i].IObursts[j]; } } //enter the bursts into processes 1-30's respective arrays. cout<<endl<<"Enter the degree of multiprogramming."<<endl; cin>>n; //the amount of processes the CPU can handle at one time. while(processesDone<30) { //ok here is where im not really sure what to code so ill throw out //some ugly pseudocode //for(count = 0; count < n; count++) //push processes[i] onto rdyqueue. //make their arrivalTimes = systemClock; //systemClock = processes[0].CPUburst[CPUcount]+10 second //context switch; //compute all the other numbers and add 1 to the counters, this i //know how to do. make sure to add IOburst[0] to processes[0] //wait time. //now pop this guy from the rdyQueue and push him onto a //waitingQueue. //now i know i have to push the next processes onto the ready //queue add his burst to the system clock and add the pointers //etc. //now this is where i get confused, i want to get processes[0] //back into the rdyQueue but in order to do that i have to make //sure (processes[1].CPUburst+context switch)>=processes[0]. //wait. How can i add and subtract two different struct values //which are on two different queue data structures? */
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages! |
|
|||||
|
Depending on the complexity, these can get very nasty. My Dad worked most of his career writing scheduling programs.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Programming is a branch of mathematics. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Scheduling Program | elemenohpee | General Programming | 1 | 08-24-2007 12:06 PM |
| ! Need urgent help ! Drawing program using cygwin | siren | C and C++ | 0 | 05-26-2007 11:51 PM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |
Goal: 100,000 Posts
Complete: 98%