Monday, March 26, 2012

Shortest Job First Simulation in C#


Where did I go wrong. How do I make this right


public ShortestJobFirst(int pollTime)
        {
            if (pollTime < 1)
            {
                throw new ArgumentOutOfRangeException(Resources.PollTimeGreaterThanZero);
            }

            _pollTime = pollTime;
        }

       
        public void Execute(Runner runner)
        {
            List readyQueue = new List(runner.ProcessLoad);
            while (readyQueue.Count > 0)
            {
                try
                {
                    // select the process that is eligible to run with the smallest remaining burst time
                    Process p = readyQueue.Where(x => x.ArrivalTime <= runner.Time).OrderBy(x => x.BurstTime - x.Data.UtilizedCpuTime).First();
                    runner.UtilizeCpu(p, _pollTime);
                    if (Process.IsComplete(p))
                    {
                        runner.LogProcessMetrics(p);
                        readyQueue.Remove(p);
                    }
                }
                catch (InvalidOperationException)
                {
                    runner.SkipIdleCpuTime();
                }
            }
        }

        public override string ToString()
        {
            return string.Format(CultureInfo.InvariantCulture, "Shortest Job First (Job Time = {0})", _pollTime);
        }
}

Saturday, March 24, 2012

Servlet Lifecycle

StagePurposeWhen it happensCan be Overridden
init() Initialize servlet before client request After the servlet instance is created Possibly, when you have an initialization code
service() determine the HTTP method (Get/post) When the client's request comes in No, unlikely
doget() dopost Initialize servlet before client request Invoked by service() whether the method is post or get Always. this where the programmer's work is suppose to be in

Friday, March 2, 2012

Network Layer Glossary


Host-- A node in the computer network that provides information services and applications to other nodes
End System- Nodes Connected to the internet
Subnet-- Division of a network
Transmission Lines-- Carries alternating current to the of frequency containing information.
Switching Elements--
Congestion-- Quality of service deteriorates due to the overflow of data. Typical effects include queueing delay, packet loss or the blocking of new connections.
Flow Control-- Management of Data transmission rate between two nodes to prevent a fast sender from outrunning a slow receiver.
Connection Management-- Manages Connections
Virtual Circuit--Allows higher level protocols to avoid dealing with the division of data into segments, packets, or frames. Delivered by Packet modes. A path from source to destination in Connection Oriented Service.
Datagram-- Packets in a connection less service that are injected into a subnet individually and independently.