Esempio n. 1
0
 void add_segments(List <double> size, List <string> name)
 {
     for (int i = 0; i < size.Count; i++)
     {
         segment s = new segment(size[i], process_counter.ToString(), name[i]);
         temp_seg_list.Add(s);
     }
 }
Esempio n. 2
0
        void startingSegments(double memory_size, List <hole> holes)
        {
            double start, range;
            double current = 0;

            for (int i = 0; i < holes.Count(); i++)
            {
                start = holes[i].start;
                range = holes[i].size;
                if (current < start)
                {
                    segment s = new segment(start - current, "0", "Segment");
                    s.start = current;
                    seg_list.Add(s);
                    temp_seg_list.Add(s);
                    current = start + range;
                }
                else
                {
                    current = start + range;
                }
            }
            if (current < memory_size)
            {
                segment s = new segment(memory_size - current, "0", "Segment");
                s.start = current;
                seg_list.Add(s);
                temp_seg_list.Add(s);
            }
            for (int i = 0; i < temp_seg_list.Count; i++)
            {
                process p0 = new process(process_counter.ToString(), "Initially allocated " + (i + 1));
                temp_seg_list[i].code = process_counter.ToString();
                p_list.Add(p0);
                process_counter++;
            }
        }