Wednesday, 24 June 2015

Important Points to remember for Operating System

Test and Set Operation:

This operation reads the memory block. If the memory is allocated, then it keep the bit 1 otherwise it allocates the memory and set the bit from 0 to 1

It works as TestAndSet(a,b)

  1. Read the value of b
  2. Value of b goes to a
  3. b=True
It can be used for locking and unlocking memory

System Calls: The System Call is the Request for Running any Program and for Performing any Operation on the System. 

Scheduler:
  • Long term scheduler: determines which programs should be admitted for execution and when and which ones should be exited
  • Middle Term scheduler transfers data from secondary memory to primary memory and vice versa
  • Short time scheduler: timely allocates CPU to ready processes.
Fork System Calls: 
  • Successful: returns ParentID-> childPID and ChildProcess->0
  • Unsuccessful: returns ParentID ->1
Threads: Light weight process because they share code and data. However, every thread have its own register and stack.


Notes of Important concepts of Operating Systems

Detailed Architecture

  • Hardware
  • Machine Code
  • Operating System
  • System Programming Language
  • Compiler
  • Application Programming Language
  • Application Package
Operating System: 
  • Written in Low Level Language
  • Collection of programs which controls the resources of system
Basic Operations:
  • Device Configuration
  • File Management
  • Memory Management
  • Interface platform
Types of Operating Systems:
  • Batch Processing
  • Real Time
  • Time Sharing
Special Features of Operating Systems
  • Multi-tasking
  • Multi-programming
  • Parallel Processing
  • buffering
  • Spooling: Simultaneous Peripheral Operation On-line

Tuesday, 23 June 2015

Discrete Math concepts of National Level Exam (Previous Questions)

1. The number of integers between 1 and 250 that are divisible by 2, 5 and 7 is
(A) 2 (B) 3
(C) 5 (D) 8

2*5*7=70
250/70=3.___=3=B

Concept
Numbers which can be divisible by any of the three: n(A) + n(B) + n(C) - n(A and B) - n(B and C) - n(A and C) + n(A and B and C)
Numbers which can be divisible by all three: n(A and B and C)
Numbers which can be divisible by atleast two of three: n(A and B) - n(B and C) - n(A and C) + n(A and B and C)


2. An undirected graph possesses an eulerian circuit if and only if it is connected and its vertices are
(A) all of even degree
(B) all of odd degree
(C) of any degree
(D) even in number

An Euler path is a path that uses every edge of a graph exactly once. 
An Euler path starts and ends at different vertices.

An Euler circuit is a circuit that uses every edge of a graph exactly once.
An Euler circuit starts and ends at the same vertex.
It may cross/ repeat vertices but not edges
If number of odd vertices in path is exactly 2, then it is Euler Path,
If a graph G has an Euler circuit, then all of its vertices must be even vertices.
In every graph, the sum of the degrees of all vertices equals twice the number of edges. 
To find an Euler path or an Euler circuit:
  1. Make sure the graph has either 0 or 2 odd vertices. 
  2. If there are 0 odd vertices, start anywhere. If there are 2 odd vertices, start at one of them. 
  3. Follow edges one at a time. If you have a choice between a bridge and a non-bridge, always choose the non-bridge. 
  4. Stop when you run out of edges. 
This is called Fleury’s algorithm, and it always works!



Fuzzy Logic in Soft Computing

In our day to day life, we use those terms which are imprecise in nature. It rains heavily. Boy is Good. Whether is cloudy. The question is How much?

Fuzzy deals with handling of this imprecise theory.

Stochastic Uncertainty: (80%)
Lexical Uncertainty: Tall man, hot days, stable currencies.

Conventional Boolean Set Theory:
The answer is 0 or 1.
The crisp boundary is framed

Fuzzy Set Theory:
The answer is varied in between 0 and 1
The boundary is gradual.

Fuzzy Logic: Reasoning with qualitative information
Fuzzy set differs from crisp set in terms of membership

Membership/ Character/ Discriminative predicate

x={1,2,3,4,6,8,10}
u belongs to x.
u is membership function of x which is either 1 or 0. // for crisp set

Us is between 0 and 1 (both are included) // for fuzzy set
Characteristic function: 0 <=Us<=1

Notion of truth can be modeled in fuzzy set
Member functions represent curves

Alpha-cut is a crisp set whose values are greater than 0.
Union: Maximum of both
Intersection: Minimum of both

Converting a fuzzy term in crisp value is called defuzzification
  

Sunday, 21 June 2015

Multi-dimensional Arrays in Programming

Two Dimensional Arrays

int A[4][2]
A[rows][columns]

Storage in memory: row major order. Memory storage is always one dimensional storage.

Two Dimensional arrays are always rows followed by columns

It is just like there are 10 classes, each class have 10 students and 1 monitor and every all monitors are ordered by one teacher.

Teacher[10][10].

Teacher

  • Monitor1
    • Student 1
    • Student 2
    • Student 3
    • [upto 10]
  • Monitor2
    • Student 1
    • Student 2
    • Student 3
    • [upto 10]
  • Monitor3
    • Student 1
    • Student 2
    • Student 3
    • [upto 10]
  • and so on
Similarly with 3 Dimensions 

It will go at 3 levels. 

Introduction to Functions in Programming

Functions is a module which takes input and gives some output.

It can be

  • inbuilt
  • user defined
What happens in black-box is not required and is hidden. These hidden details are said to be abstract. 

Break large program into smaller problems and compose them together into one unit later on. Using of standard library functions is good programming practice to save time.

Functions are used to
  • Hiding the details
  • incorporate changes
  • Facilitates modular programming
  • Reusable
We have caller and callee. Caller can give any number of calls to callee. This is called re-usability.

Function cannot be written completely in other function. Main() is the very first function which is used. The control flow can move from one function to another as called by caller and return back. 

Prototype tells the blackbox description of function i.e. inputs, number of inputs, types of inputs, return types etc. 

Calling programs pass actual parameters. Information is accessed by called functions using formal parameters. 

Accessing arrays with pointers | Strings in Programming

We can access array using *(ptr+i)

So, let us see what this means

(ptr+i) for i=0, means ptr i.e. *(ptr+i) for i=0 is *ptr
When we add i, it means adding i number of locations to ptr and finding its value at ptr+i.

sizeof(x) operator tells the size of that variable x.

Arithmetic with Pointers

Increment/ Decrements
Comparing pointers
Subtraction with pointers

String

Sequence of character is referred to as string. The last character of string is '\0' null character.

char s1[]="H"; //constant pointer to string
char s2='H'; //
char *s3="H"; //pointer to constant string

sizeof(s1); //gives 2
sizeof(s2); //gives 1
sizeof(s3); //gives 2

Notion of the string is not a basic datatype in C. String is an array of character i.e. it is an aggregate data type of characters.

Functions of String:
char* strcmp(char *str1,char *str2)