Lost Password?


Go Back   CodeCall Programming Forum > Software Development > General Programming

General Programming Non language specific, Assembly, Linux/Unix, Mac and anything not covered in other topics. Talk about Programming Theory here.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-27-2006, 09:49 PM
bryan bryan is offline
Newbie
 
Join Date: Nov 2006
Posts: 5
Rep Power: 0
bryan is on a distinguished road
Default can sum1 help me in making a CPU scheduling algorithm program in c?

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!!....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 11-28-2006, 08:55 AM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 9,224
Last Blog:
Ext JS or Ext GWT
Rep Power: 20
Jordan is just really niceJordan is just really niceJordan is just really niceJordan is just really nice
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-28-2006, 12:55 PM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 3,276
Last Blog:
wxWidgets is NOT code ...
Rep Power: 36
WingedPanther is a name known to allWingedPanther is a name known to allWingedPanther is a name known to allWingedPanther is a name known to allWingedPanther is a name known to allWingedPanther is a name known to all
Default

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

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


All times are GMT -5. The time now is 01:04 PM.

Contest Stats

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

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 98%

Ads