Exemplo n.º 1
0
        public void Interrupt(ReadTokenRequest rFinishedRequest)
        {
            ProcessTableEntry curProcess = m_dProcessTable[rFinishedRequest.ProcessId];
            int NumOfProcess             = rFinishedRequest.ProcessId;

            //when the token is null, EOF has been reached.
            //we write the value to the appropriate address space of the calling process.
            if (rFinishedRequest.Token == null)
            {
                curProcess.AddressSpace[rFinishedRequest.TargetVariable] = double.NaN;
            }
            else
            {
                //translate the returned token into a value (double).
                double token = Convert.ToDouble(rFinishedRequest.Token);

                curProcess.AddressSpace[rFinishedRequest.TargetVariable] = token;
            }

            curProcess.Blocked    = false;                  //so we will not stuck in the "idle" later on...
            curProcess.outOfBlock = CPU.TickCount;          //the process isn't blocked any more... hence, its ready. so we save the time... for later calculate max starvation

            if (m_dProcessTable[NumOfProcess].Done != true) //didn't finish so i need to schedual via policy
            {
                m_spPolicy.AddProcess(NumOfProcess);
            }


            //activate the next request in queue on the disk.
            if (m_lReadRequests.Count > 0)
            {
                //need to activate next request...
                Disk.ActiveRequest = m_lReadRequests[0];
                m_lReadRequests.RemoveAt(0);
            }


            if (m_spPolicy.RescheduleAfterInterrupt())
            {
                ActivateScheduler();
            }
        }
Exemplo n.º 2
0
        public void Interrupt(ReadTokenRequest rFinishedRequest)
        {
            //implement an "end read request" interrupt handler.
            //translate the returned token into a value (double).
            //when the token is null, EOF has been reached.
            //write the value to the appropriate address space of the calling process.
            //activate the next request in queue on the disk.

            ProcessTableEntry active_process = m_dProcessTable[rFinishedRequest.ProcessId];
            String            var_name       = rFinishedRequest.TargetVariable;
            String            var_value      = rFinishedRequest.Token;

            if (var_value == null)
            {
                active_process.AddressSpace[var_name] = double.NaN;
            }

            else
            {
                active_process.AddressSpace[var_name] = Convert.ToDouble(var_value);
            }

            m_dProcessTable[rFinishedRequest.ProcessId].Blocked = false;
            m_spPolicy.AddProcess(rFinishedRequest.ProcessId);
            m_lReadRequests.Remove(rFinishedRequest);
            if (m_lReadRequests.Count > 0)
            {
                ReadTokenRequest awaiting_procees_request = m_lReadRequests.First();
                //m_dProcessTable[awaiting_procees_request.ProcessId].Blocked = true;
                Disk.ActiveRequest = awaiting_procees_request;
            }
            if (m_spPolicy.RescheduleAfterInterrupt())
            {
                ActivateScheduler();
            }
        }