Warning

 

Close

Confirm Action

Are you sure you wish to do this?

Confirm Cancel
BCM
User Panel

Site Notices
Posted: 10/24/2001 10:30:45 PM EDT
I've got an assignment due in my Operating Systems class due in two days.  The time to do it is plentiful, but the knowledge in the Jew's brain is not.  I've been working with so much Java lately, that there's no way I can do this assignment in C++ ...not to mention they never taught us the language at all, so I just taught myself the "basics".

Here's the deal, I'll let the requirement guidelines in the "Problem Statement" section speak for itself:
[url]http://www.eng.auburn.edu/department/csse/classes/comp3500/index.html[/url]

I understand the concept, and I figure I'll probably want to use FIFO, LRU, and Second-Chance as my 3 algorithms.  I'm not asking anybody to WRITE the darn thing for me, perish the thought.  But if you have any resources which I could use, i.e. out of a book, a URL, an old algorithm library laying around, etc....PLEASE direct me.  I need help desperately on this assignment, especially since I'm totally stumped how I'm going to approach the assignment.  Chances are the only thing I'll even know how to write is the simple driver class (er, "main function", geez I can't even get the names right) [:\]

I'm in your debt if you can help me out.
Link Posted: 10/24/2001 10:45:23 PM EDT
[#1]
Looks like you haven't been doing your homework. . . . [:D]

Is this the producer-consumer problem in

http://www.eng.auburn.edu/department/csse/classes/comp3500/projects/Project%201A.pdf

or is it one of the other assignments??  There are seven "homework" and two "project" things listed.  (I didn't look at the second project since it's apparently a MS-Word file. . . .)
Link Posted: 10/24/2001 10:47:22 PM EDT
[#2]
WHOOPS, sorry.
Pick "Project Assignments", then it's
"Project 2B.DOC"

Luckily, Proj #1 was written in good ol' Java...no problems there.  Project #2 is going to be difficult, though.
Link Posted: 10/24/2001 10:55:14 PM EDT
[#3]
Link Posted: 10/24/2001 11:03:17 PM EDT
[#4]
Definitely looks like an all-nighter.  

If you have any specific problems with the code post 'em on here.  I'm sure I'm not the only geek here.
Link Posted: 10/25/2001 2:25:35 PM EDT
[#5]
the paging system project I did last semester was the one I didn't really finish. I doubt this cna be done in two days. I didn't read the whole thing, but if it reguires the stuff ours did it's a fairly long thing to code
Link Posted: 10/25/2001 2:50:37 PM EDT
[#6]
The jews grades so far, we better help out here:

AR15jew.....85.....70.....0.....no quiz

Ohhh wait nevermind, this place isn't accredited.
                                                                       
                                                                               
                                                                                       
                                                                                               
                                                                                                     
Link Posted: 10/25/2001 3:25:14 PM EDT
[#7]
which part of C++ do you need help with? I can't really help you with the system call part because I only programmed in Windows and DOS environments. But you should be able to find reference info easily on that. Other than that I should be able to help.
Link Posted: 10/25/2001 6:09:08 PM EDT
[#8]
What are you having trouble with? This project doens't seem TOO hard, it just takes a little time. I've got my C++ books laying around. Just let me know what you need and I might be able to help.


BTW, what is an LRU? Don't think I heard of that term before.
Link Posted: 10/25/2001 7:33:41 PM EDT
[#9]
Quoted:
The jews grades so far, we better help out here:

AR15jew.....85.....70.....0.....no quiz

Ohhh wait nevermind, this place isn't accredited.
View Quote


Quizzes are just extra-credit...but yes, I have a lot of 0 homework grades.  I can never get them turned in on time, I usually opt to turn in my Scheme assignments instead.  Nevertheless, this project will bring me down if I can't figure out how to do it.  Time never was the issue, ignorance is - I still know no way in hell of approaching this, so I'll probably end up taking a failure on it.
Link Posted: 10/25/2001 7:52:18 PM EDT
[#10]
Quoted:
BTW, what is an LRU? Don't think I heard of that term before.
View Quote

Least Recently Used

As for part two... well I can't help you on the C++ end (they teach us ADA here of all things).  I have a specification (i.e. procedure names and parameters, and some comments about what they should do) for almost this exact problem.  The spec is written in Ada though.  Could give you some ideas maybe.

Probably talking either an array of records (easier) or linked list (more complex).  Each time an entry gets called, you check the "cache" (the array of records).  If it's in there, you update its use and move on.  If not, you page in the new appropriate val, dumping the appropriate old val.

Well, if I'm making any sense, or you want a look at the spec, or want to otherwise contact me... I'm editing my profile to allow my email to be seen.

Viper Out
Link Posted: 10/25/2001 7:52:58 PM EDT
[#11]
you really was givin a good one in two days time!!! C++ not knowing the language WELL!!!

Link Posted: 10/25/2001 7:59:24 PM EDT
[#12]
Quoted:
What are you having trouble with? This project doens't seem TOO hard, it just takes a little time. I've got my C++ books laying around. Just let me know what you need and I might be able to help.


BTW, what is an LRU? Don't think I heard of that term before.
View Quote


LRU - Least Recently Used

This really looks like a pretty easy assignment.  Since you could use C or C++, I'd opt for C.  More straightforward than doing this in C++, and quicker.  All you've got to do is allocate an array of either 4 or 8 to hold int's. Using the appropriate algorithm, the "page" is either in "memory" (the array), or it isn't.
Link Posted: 10/25/2001 7:59:43 PM EDT
[#13]
Did some hunting on the net (God bless Google, and the people that made it).

[url]http://www.geocities.com/Vienna/7079/src/paging.txt[/url]

Well.  That's all I found for now... hope it helps.

Good luck.

Viper Out
Link Posted: 10/25/2001 8:06:20 PM EDT
[#14]
A flowchart should help some. I know it's not much though, but I don't do C. Should help break it down into bite-size chunks if the rest of it will come along.
Link Posted: 10/25/2001 8:14:28 PM EDT
[#15]
do you guys know were there is info on algorithms! NOT the language! i mean in C++
but not language reference.
Link Posted: 10/25/2001 8:18:58 PM EDT
[#16]
Quoted:
All you've got to do is allocate an array of either 4 or 8 to hold int's.
View Quote


Wouldn't it be an array of records, rather than ints? You would want to keep track of the time last used for LRU.  If you needed to keep track of any other info (how many times page has been accessed), you could just slam it into the record structure as well.

Viper Out
Link Posted: 10/25/2001 8:30:09 PM EDT
[#17]
If you want, I can send you an old project I did that held an array or records. It might give you an idea. Maybe you can switch things around.
Link Posted: 10/25/2001 10:03:27 PM EDT
[#18]
Quoted:
If you want, I can send you an old project I did that held an array or records. It might give you an idea. Maybe you can switch things around.
View Quote


Sure, that'd give me something to work with as far as my paged memory.  I'm still trying to develop just ONE working algorithm for it.  Plus, I gotta learn how to do "Math.Random" numbers, or C++'s functional equivalent.  Too bad C++ doesn't have a website like www.java.sun.com  ...makes things SO much tougher.
Link Posted: 10/25/2001 10:39:52 PM EDT
[#19]
Plus, I gotta learn how to do "Math.Random" numbers, or C++'s functional equivalent.  Too bad C++ doesn't have a website like www.java.sun.com  ...makes things SO much tougher.
View Quote


The generic random number generator in C is rand().  I think the library is stdlib.h.  It returns a number from 0 to RAND_MAX.  




Link Posted: 10/25/2001 10:57:53 PM EDT
[#20]
Your best bet is to go to this below site and post your question there.  Make sure to post your question in its entirely and do not post a link.  Good luck,

[url]http://www.codeguru.com/[/url]
Link Posted: 10/26/2001 2:23:56 AM EDT
[#21]
For the FIFO you can use nn array of ints, but for the LRU you need an array or linked list of structures. If you use the STL in C++, the list management becomes a no brainer.

For instance, for the FIFO, you could do this:

#include
#include

const int NFRAMES = 4;

static void fifo_add( int item, int& rfaults );

static std::list fifo_list;

int main(int argc, char* argv[])
{
  int i, nfaults;

  int data[] = {7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 7, 4, 6, 5, 4, 6, -1};

  nfaults = 0;
  fifo_list.clear();
  for (i=0; data[i] != -1; i++)
     fifo_add(data[i], nfaults);
  printf("\n%d page faults.\n", nfaults);

  getchar();
  return 0;
}


static void fifo_add( int item, int& rfaults )
{
  std::list::iterator it;

  it = find(fifo_list.begin(), fifo_list.end(), item);
  if (it == fifo_list.end())
  {
     // not found
     if (fifo_list.size() == NFRAMES)
        fifo_list.erase(fifo_list.begin());
     fifo_list.push_back(item);
     printf("%d\n", item);
     rfaults++;
  }
}

BTW, if you don't see the subscript operators, it's because they were removed when I posted this message. Don't ask me why.
Link Posted: 10/26/2001 2:30:18 AM EDT
[#22]
Quoted:
Quoted:
If you want, I can send you an old project I did that held an array or records. It might give you an idea. Maybe you can switch things around.
View Quote


Sure, that'd give me something to work with as far as my paged memory.  I'm still trying to develop just ONE working algorithm for it.  Plus, I gotta learn how to do "Math.Random" numbers, or C++'s functional equivalent.  Too bad C++ doesn't have a website like www.java.sun.com  ...makes things SO much tougher.
View Quote


To generate random numbers within a range you specify, use random().
Link Posted: 10/26/2001 8:28:59 AM EDT
[#23]
Mattja,

Nice use of an array!

I can't get over the diversity that make up the members of this forum.  Just a couple of days ago, there was an audiophile discussion on high end loud speakers and now C++???

Glad to see this forum is not just a typical firearms discussion site.
Link Posted: 10/26/2001 12:27:42 PM EDT
[#24]
There's nothing hard about doing this project in C, you just have to think about the problem--get a hold of an operating systems text that describes the algorithms you are going to use.  Most have example code in them.  You should be able to find sample C code for the algorithms, so I wouldn't beat my brains out trying to re-invent them as long as you understand what they do.  You may have to alter them for use with your simulation.  I say "C" and not "C++" because you really aren't doing any object-oriented programming for this assignment, correct?  It's too bad they teach students Java from the get-go these days.  It confuses the hell out of everything for those just starting out--too many libraries and canned routines for everything under the sun.  No good for teaching fundamentals.

My advice is for you to learn the concepts behind paging and memory management and the rest will come easily--just stick to basic I/O like cin and cout (or fprintf and printf) and write routines that work on arrays.

Many moons ago I had to write a whole Pascal intepreter in C.  It was a struggle and very frustrating, but I look back on those days pride.  It's sort of a rite of passage.

Link Posted: 10/26/2001 2:06:14 PM EDT
[#25]
Heres a sample "Record holder" that I used last year in school as a group project:

//  The file contains the record holder


/********************************************************************
Record_Holder stores any type data, as long as it has
a static member function file()
that returns the location of the file.
Also, the record needs to overload cout.

Member functions so far:
display() -- sequentially displays the data
addData() -- appends new data to the ends of its respective file

Functions to be put in:
search() -- finds a specific file, should overload == in record classes
sort() -- sort alphabetically or sequentially

The only member data is size, which is saved in another file.
size will be helpful for sorting.
*********************************************************************/
template
class Record_Holder {
private:
int size;
public:
Record_Holder();
~Record_Holder();
void display();  // Displays all data
void addData(T input);
void search(T in);
};

template
Record_Holder< T >::Record_Holder()
{
ifstream Index( "index.dat" );
Index >> size;
Index.close();
}

template
Record_Holder< T >::~Record_Holder()
{
ofstream Index( "index.dat" );
Index << size;
Index.close();
}

template
void Record_Holder< T >::display()
{
ifstream inData( T::file(), ios::in );

if( !inData ) {
cerr << "File could not be opened." << endl;
exit(1);
}

T lookatme;

inData.read(
reinterpret_cast( &lookatme ),
sizeof( T ) );

while( inData && !inData.eof() ) {
cout << lookatme;

inData.read(
reinterpret_cast( &lookatme ),
sizeof( T ) );
}
}

template
void Record_Holder< T >::addData( T input )
{
ofstream outData( T::file(), ios::app, ios::binary );

if( !outData ) {
cerr << "File could not be opened." << endl;
exit(1);
}

outData.seekp( size * sizeof( T ) );
outData.write(
reinterpret_cast( &input ),
sizeof( T ) );

size++;

outData.close();
}
Link Posted: 10/26/2001 2:59:39 PM EDT
[#26]
gun owning computer nerds [:)]
I should graduate with a BS in CS at the end of this semester

Quoted:
Mattja,

Nice use of an array!

I can't get over the diversity that make up the members of this forum.  Just a couple of days ago, there was an audiophile discussion on high end loud speakers and now C++???

Glad to see this forum is not just a typical firearms discussion site.
View Quote
Link Posted: 10/27/2001 3:12:32 AM EDT
[#27]
Quoted:
Mattja,

Nice use of an array!

I can't get over the diversity that make up the members of this forum.  Just a couple of days ago, there was an audiophile discussion on high end loud speakers and now C++???

Glad to see this forum is not just a typical firearms discussion site.
View Quote


Yep, we have a diverse crowd over here. We aren't all drooling gun nuts as the media would have people believe. :)
Close Join Our Mail List to Stay Up To Date! Win a FREE Membership!

Sign up for the ARFCOM weekly newsletter and be entered to win a free ARFCOM membership. One new winner* is announced every week!

You will receive an email every Friday morning featuring the latest chatter from the hottest topics, breaking news surrounding legislation, as well as exclusive deals only available to ARFCOM email subscribers.


By signing up you agree to our User Agreement. *Must have a registered ARFCOM account to win.
Top Top