Alek Modi

Alek Modi
Follow You Heart!

Thursday, June 7, 2012

Operating System Process Scheduling Simulation Project


SOURCE CODE FOR PROCESS SCHEDULING SIMULATOR    


 Download source code


Process/Job Characteristics
1. Two ways to input jobs file. 
a. Import Files
b. User Input

2. Scheduling can be done in two techniques 
a. SJF
Imported Data
Processed Data (Sorted in ascending order)
b. FCFS
Imported Data
Processed Data (First Come First Served basis)
C. Round Robin Scheduling
Process ID : 1 - 10 (unique)
Process Arrival Time : Jobs should arrive to the job queue one after another with intervals of 1 to 10 time units (unique)
Process Type : System
Length of Each CPU Burst : 1-12

CPU Scheduling
· Round Robin (Quantum 4)
Simulation Model Parameters

Simulate the Execution of the processes . The simulation program should be able to compute for the average turnaround time, waiting time, job throughput in order to evaluate the performance of the operating system.

Display/ Output 
· Average turnaround time
· Waiting time
· Job throughput
· CPU Gantt chart


Object Oriented Software Development Concepts:


1. Class:
A class is simply a representation of a type of object. It is the blueprint/ plan/ template that describe the details of an object. A class is the blueprint from which the individual objects are created. Basically, OOPs encapsulates names, attributes (data), and operations (behavior) into packages called Classes, where data and member functions of the class are immediately tied together.
Syntax of a class in C++;



2. Object:
In pure OOP terms an object is an instance of a class. Generally, an object can be considered a "thing" that can perform a set of related activities. The set of activities that the object performs can be called as object's behavior. For instance from example 1.1,
Let’s create one object, person student = new person(“Sam”,21)
So here, student (object) can hold all the characteristic of class person.


3. Encapsulation:
The encapsulation is the inclusion within a program object of all the resources need for the object to function - basically, the methods and the data. In OOP the encapsulation is mainly achieved by creating classes, the classes expose public methods and properties. The class is kind of a container or capsule or a cell, which encapsulate the set of methods, attribute and properties to provide its indented functionalities to other classes. In example 1.1, class person {...} has encapsulated variables, name & age and methods, print(); and person(); this is encapsulation.

4. Message passing & 5. Message receiver
A method implements behavior, which is defined by most of the OOP authors as: “Behavior is how an object acts and reacts, in terms of its state changes and message passing.” Means, a program consists of a network of interconnected objects that call upon each other to solve a part of the puzzle. Each object has a specific role to play in the overall design of the program and is able to communicate with other objects. Objects communicate through passing messages, requests to execute a code.


For example 1.2,
Student.person(“Matt”,26);
Student person : “matt” param1: 26 param2
Student.print();
This object ‘student’ is called the receiver, which is the object the method operates on. An exception exists with C++'s static member functions which do not have a receiver, or "this" pointer. The example 1.2 is some common notations for invoking a method, and this invocation can be called a message (or message passing).


6. Instantiation:
Instantiation is one of the most important mechanisms for code reuse in object-oriented programming languages. Instantiation is the use of object classes. (An object class is a set of objects that share a common structure and a common behavior). Instantiation is fundamentally a word for the use of inheritance. Programmers can define object classes, define their own kinds of objects, and instantiate them as needed. This is one of the most important mechanisms for code reuse in object-oriented programming languages.
To create an instance of the nested class, use the name of the container class followed by the dot and then followed by the name of the nested class:
Container Instance = new Container()
After instantiating a class, now you can assign values to the instance's properties and fields and invoke class methods.


7. Polymorphism:
Poly – morphism is a generic term that means 'many shapes'. More precisely Polymorphism means the ability to request that the same operations be performed by a wide range of different types of things. In OOP the polymorphism is achieved by using many different techniques named method overloading, operator overloading and method overriding.
For example, let’s say there is a main class vehicle with a method called wheels(); and there are two subclasses, class car – 4 wheels and class bike – 2 wheels. Here one method was used by two different classes


8. Overloading
a. Method Overloading:
The method overloading is the ability to define several methods all with the same name. Method overloading should not be confused with forms of polymorphism where the correct method is chosen at runtime.
 


b. Operator Overloading:
The operator overloading is a specific case of polymorphisms in which some or all of operators like +, - or == are treated as polymorphic functions and as such have different behaviors depending on the types of its arguments. For example ‘+’ operator can be used for adding integer or for concatenating two strings or for incrementing values.


9. Shadowing:
A member can shadow another member in a parent class if it has the same name and parameters, if any. In that case, the new member supersedes the old version. This is very similar to the way a class can override a parent class member, but shadowing changes the way polymorphism works.



10. Member:
A class can have both data members and functions members associated with it. Unlike the built-in types, the class can encapsulate several variables and functions and those are called members.
In example 1.2, variables and methods - name, age, print (), person () are the members of the class person.


11. Instance:
If you look at the word instantiation you can see that it is derived from the word instance. An instance of a class is an object that is described by that class. Instantiation of a class is the creation of a new instance of that class.
When a new instance of an object class is created, it has its own set of instance variables, and it shares the method implementations with other instances of its class.


12. Inheritance:
Ability of a new class to be created, from an existing class by extending it, is called inheritance.

According to the above example the new classes (Bike and car), which are called the derived classes or subclasses, inherits the members of an existing class (Vehicle), which is called the base class or super-class. The class Bike and Car can extend the functionality of the class Vehicle by adding new types and methods and by overriding existing ones.


13. Composition:
Composition is about expressing relationships between objects. Let’s say about the vehicle example in example 1.3. A vehicle has a gas tank. A vehicle has a pair of wheels. A vehicle has an engine. The phrase "has a" implies a relationship where the vehicle owns, or at minimum, uses, another object. It is this "has a" relationship which is the basis for composition.


14. Data hiding:
The objects of a class have members which can be integers, characters, arrays, functions or even structures. Now these members can be either Private, Public or Protected.
Public allows you to use all the members from outside the class.
Private allows you to access all the members from inside the class only.
Protected allows only the friend functions to access the members.
Data hiding is an important characteristic of OOP for securing data, so an object can only be associated with data in predefined classes or templates, the object can only "know" about the data it needs to know about.
In example 1.1, any object of the class person cannot access the private variables – name and age, in the class. This restriction is called data hiding.


15. Principle of substitution:
In class hierarchies, it should be possible to treat a specialized object as if it were a base class object.
The basic idea of substitution principle is very simple. All code operating with a pointer or reference to the base class should be completely transparent to the type of the inherited object. It should be possible to substitute an object of one type with another within the same class hierarchy. Inheriting classes should not perform any actions that will invalidate the assumptions made by the base class.


16. Attribute:
Attributes are the properties that specify the information associated with a component, such as its name, description, and color. Attributes determine how a component will look and behave. For example, the Push Button Control has an attribute named label that specifies the text displayed on the button. You can create two instances of the Push Button Control on your frame and have one display "OK" and the other display "Cancel," simply by specifying a different value for the label attribute of each instance.
You can define attributes with attribute statements in CLASS blocks:
scope data-type attribute-name/(attribute-options);
Attribute names can be up to 256 characters long.


17. Behavior:
Here, I assume, behavior means the scope of the data members. If a variable is declared globally then it will be access by any method in the whole program. The lifespan of the global variable is till the program is terminated. On other hand there are local variables which declared inside the method or a class. Thus the behavior of that local variable is used only inside the class. Thus the behavior of any data/method depends by the way it is declared in the program.


18. Interface:
The Interface separates the implementation and defines the structure, and this concept is very useful in cases where you need the implementation to be interchangeable. Apart from that an interface is very useful when the implementation changes frequently.
Interface can be used to define a generic template and then one or more abstract classes to define partial implementations of the interface.
public interface ILogger{
bool IsThisLogError { get; }
}


19. Constructor:
It prepares the new object for use, often accepting parameters which the constructor uses to set any member variables required when the object is first created. It is called a constructor because it constructs the values of data members of the class.
In example 1.1 (see above), the function -> Person(sting str, int n){ … } is a construction which is used to initialize the private member variables – name and age in the class.



20. Abstraction:
Abstraction is the process by which data and programs are defined with a representation similar in form to its meaning, while hiding away the implementation details. Abstraction captures only those details about an object that are relevant to the current perspective.
Abstraction can apply to control or to data: Control abstraction is the abstraction of actions while data abstraction is that of data structures.
 Control abstraction involves the use of subprograms and related concepts control flows
 Data abstraction allows handling data bits in meaningful ways. For example, it is the basic motivation behind datatype.
Abstraction is essential in the construction of programs. It places the emphasis on what an object is or does rather than how it is represented or how it works. Thus, it is the primary means of managing complexity in large programs.