Main()
float *stdnt, *exams, *assns, *total
int stu_count, assn_count, test_count
1. Show page table
stu_count = Load( *stdnt, "stdnt.data" )
3. Show page table
//The following call will cause the
// resulting grade array to be placed
// in a real frame.
Allocate( *total, stu_count )
4. Show page table
Load( *assns, "assns.data" )
6. Show page table
Calc( *total, *assns, .4, stu_count )
8. Show page table
Load( *exams, "exams.data" )
10. Show page table
Calc( *total, *exams, .6, stu_count )
12. Show page table
Print( *stdnt, *exams, *total, count)
14. Show page table
Exit
|
Load( *Array, Fname )
Open Fname
// Read 1st record of file to
// determine number of entries
size_info = read( Fname )
// Allocate memory to hold records to
// be read in. At this point, memory
// for the array will be placed in a
// real memory frame.
// * Allocate function is system call
// - not in vm space *
Allocate( *Array, size_info )
While ( Not = EOF )
Read Fname into Array
EndWhile
2. & 5. & 9. Show page table
Return size_info
|
Print( *stdnt, *exams, *total, count )
For ( ndx = 0; ndx < count; ndx++)
Do
// For each student, display
// grade info
Display stdnt[ndx)
Display exams[ndx];
Display total[ndx];
EndFor
13. Show page table
Return
|
Calc( *total, *grades, wgt, count )
// accessing stdnt array
For ndx = 0, ndx < count, ndx++
Do
total[count] +=
grades[count] * wgt;
Done
7. & 11. Show page table
|