Deploying the best E-Resources for Software Engineering Students

We at IT Engg Portal, provide all the Computer and IT Engineering students of Pune University with well compiled, easy to learn notes and other E-resources based on the curriculum

Power Point Presentations and Video Lectures for Download

We provide the most recommended power point presentations and Video Lectures from the most prominent Universities for most of the difficult subjects to ease your learning process

Bundling Codes for your Lab Practicals

Deploying the best of available E-Resources for Tech Preparation (Campus Placements)

The Complete Placement Guide

Our Team has worked hard to compile this E-Book for all students heading for Campus Placements. The book is a complete solution for Technical Preparation for Campus Placements.

Pune University's most viewed website for Computer and IT Engineering

With more than 4,00,0000 pageviews from 114 countries over the globe, we are now the most viewed website for Ebooks and other E- Resources in Computer and IT Engineering

Showing posts with label Sem 6. Show all posts
Showing posts with label Sem 6. Show all posts

Sunday, July 29, 2012

Mutex and Semaphore : A Deeper Explanation - Operating Systems : TE [Comp - Sem 6] [I.T. Sem 5]


Let us first understand, what is Mutex aka Mutual Exclusion.
Mutex is the short-form for mutual exclusion object. In computer programming, a mutex is a program object that allows multiple program threads to share the same resource, such as file access, but not simultaneously. When a program is started, a mutex is created with a unique name. After this stage, any thread that needs the resource must lock the mutex from other threads while it is using the resource. The mutex is set to unlock when the data is no longer needed or the routine is finished.


Mutual exclusion, in computer science, refers to the problem of ensuring that no two processes or threads (henceforth referred to only as processes) can be in their critical section at the same time. Here, a critical section refers to a period of time when the process accesses a shared resource, such as shared memory. The problem of mutual exclusion was first identified and solved by Edsger W. Dijkstra in his seminal 1965 paper titled: Solution of a problem in concurrent programming control.
A simple example of why mutual exclusion is important in practice can be visualized using a singly linked list
In such a linked list the removal of a node is done by changing the “next” pointer of the preceding node to point to the subsequent node (e.g., if node i is being removed then the “next” pointer of node i-1 will be changed to point to node i+1). In an execution where such a linked list is being shared between multiple processes, two processes may attempt to remove two different nodes simultaneously resulting in the following problem: let nodes i and i+1 be the nodes to be removed; furthermore, let neither of them be the head nor the tail; the next pointer of node i-1 will be changed to point to node i+1 and the next pointer of node iwill be changed to point to node i+2. Although both removal operations complete successfully, node i+1 remains in the list since i-1 was made to point to i+1 skipping node i (which was made to point to i+2). This problem can be avoided using mutual exclusion to ensure that simultaneous updates to the same part of the list cannot occur.

Now, let us understand another very similar terminology called  Semaphore.


What is a Semaphore ?
In programming, especially in Unix systems, semaphores are a technique for coordinating or synchronizing activities in which multiple processes compete for the same operating system resources. A semaphore is a value in a designated place in operating system (or kernel) storage that each process can check and then change. Depending on the value that is found, the process can use the resource or will find that it is already in use and must wait for some period before trying again. Semaphores can be binary (0 or 1) or can have additional values. Typically, a process using semaphores checks the value and then, if it using the resource, changes the value to reflect this so that subsequent semaphore users will know to wait.
Semaphores are commonly use for two purposes: 
  • to share a common memory space and 
  • to share access to files. 
Semaphores are one of the techniques for interprocess communication (IPC). The C programming language provides a set of interfaces or "functions" for managing semaphores.

 In simple terms, a semaphore is a variable or abstract data type that provides a simple but useful abstraction for controlling access by multiple processes to a common resource in a parallel programming environment. 
     A useful way to think of a semaphore is as a record of how many units of a particular resource are available, coupled with operations to safely (i.e., without race conditions) adjust that record as units are required or become free, and if necessary wait until a unit of the resource becomes available. Semaphores are a useful tool in the prevention of race conditions; however, their use is by no means a guarantee that a program is free from these problems. 
     Semaphores which allow an arbitrary resource count are called counting semaphores, while semaphores which are restricted to the values 0 and 1 (or locked/unlocked, unavailable/available) are called binary semaphores (same functionality that mutexes have).
.




What are the differences between Mutex and Semaphore?  and
When to use mutex and when to use semaphore?

Concrete understanding of Operating System concepts is required to design/develop smart applications. 
As per operating system terminology, the mutex and semaphore are kernel resources that provide synchronization services (also called as synchronization primitives). 

Let us understand the difference between semaphore and mutex by considering the 'Producer - Consumer Problem'

The Producer-consumer problem:

Note that the content is generalized explanation. Practical details will vary from implementation.

Consider the standard producer-consumer problem. Assume, we have a buffer of 4096 byte length. A producer thread will collect the data and writes it to the buffer. A consumer thread will process the collected data from the buffer. Objective is, both the threads should not run at the same time.

Using Mutex:
   A mutex provides mutual exclusion, either producer or consumer can have the key (mutex) and proceed with their work. As long as the buffer is filled by producer, the consumer needs to wait, and vice versa.
    At any point of time, only one thread can work with the entire buffer. The concept can be generalized using semaphore.

Using Semaphore:
    A semaphore is a generalized mutex. In lieu of single buffer, we can split the 4 KB buffer into four 1 KB buffers (identical resources). A semaphore can be associated with these four buffers. The consumer and producer can work on different buffers at the same time.

Misconception:
    There is an ambiguity between binary semaphore and mutex. We might have come across that a mutex is binary semaphore. But they are not! The purpose of mutex and semaphore are different. May be, due to similarity in their implementation a mutex would be referred as binary semaphore.
  Strictly speaking, a mutex is locking mechanism used to synchronize access to a resource. Only one task (can be a thread or process based on OS abstraction) can acquire the mutex. It means there will be ownership associated with mutex, and only the owner can release the lock (mutex).
  
   Semaphore is signaling mechanism (“I am done, you can carry on” kind of signal). For example, if you are listening songs (assume it as one task) on your mobile and at the same time your friend called you, an interrupt will be triggered upon which an interrupt service routine (ISR) will signal the call processing task to wakeup.


FAQS on Mutex and Semaphore

 1. Can a thread acquire more than one lock (Mutex)?
Yes, it is possible that a thread will be in need of more than one resource, hence the locks. If any lock is not available the thread will wait (block) on the lock.

2. Can a mutex be locked more than once?
A mutex is a lock. Only one state (locked/unlocked) is associated with it. However, a recursive mutexcan be locked more than once (POSIX complaint systems), in which a count is associated with it, yet retains only one state (locked/unlocked). The programmer must unlock the mutex as many number times as it was locked.

3. What will happen if a non-recursive mutex is locked more than once.
Deadlock. If a thread which had already locked a mutex, tries to lock the mutex again, it will enter into the waiting list of that mutex, which results in deadlock. It is because no other thread can unlock the mutex. An operating system implementer can exercise care in identifying the owner of mutex and return if it is already locked by same thread to prevent deadlocks.

4. Are binary semaphore and mutex same?
No. We will suggest to treat them separately, as it was explained signalling vs locking mechanisms. But a binary semaphore may experience the same critical issues (e.g. priority inversion) associated with mutex. We will cover these later article.
A programmer can prefer mutex rather than creating a semaphore with count 1.

5. What is a mutex and critical section?
Some operating systems use the same word critical section in the API. Usually a mutex is costly operation due to protection protocols associated with it. At last, the objective of mutex is atomic access. There are other ways to achieve atomic access like disabling interrupts which can be much faster but ruins responsiveness. The alternate API makes use of disabling interrupts.

6. What are events?
The semantics of mutex, semaphore, event, critical section, etc… are same. All are synchronization primitives. Based on their cost in using them they are different. We should consult the OS documentation for exact details.

7. Can we acquire mutex/semaphore in an Interrupt Service Routine?
An ISR will run asynchronously in the context of current running thread. It is not recommended to query (blocking call) the availability of synchronization primitives in an ISR. The ISR are meant be short, the call to mutex/semaphore may block the current running thread. However, an ISR can signal a semaphore or unlock a mutex.

8. What we mean by “thread blocking on mutex/semaphore” when they are not available?
Every synchronization primitive will have waiting list associated with it. When the resource is not available, the requesting thread will be moved from the running list of processor to the waiting list of the synchronization primitive. When the resource is available, the higher priority thread on the waiting list will get resource (more precisely, it depends on the scheduling policies).

9. Is it necessary that a thread must block always when resource is not available?
Not necessarily. If the design is sure ‘what has to be done when resource is not available‘, the thread can take up that work (a different code branch). To support application requirements the OS provides non-blocking API.
For example POSIX pthread_mutex_trylock() API. When the mutex is not available the function will return immediately where as the API pthread_mutex_lock() will block the thread till resource is available.


References:







Friday, December 9, 2011

Design and Analysis of Algorithms : TE[IT - Sem 6] BE [Comp -Sem 7]

 Design and Analysis of Algorithms, a very important subject introduced in the 6th semester of Information Technology Engineering and 7th Semester of Computer Engineering of Pune University. The syllabus for Computer and IT is not same, Computer Engineering Syllabus is a bit more than IT.  Infact , Computer's syllabus is a strict superset of the IT syllabus. 


 The subject is really interesting and logical. Totally conceptual but time consuming subject. Too many algorithms in the subject make the course a bit confusing. Relatively easy to score and easy to learn subject. Scoring 65+ in this subject is not a  difficult task.


Books Recommended :


 Foreign Authors :


 Fundamentals of computer Algorithms - Horowitz and Sahani


 Local Authors : DAA - (Technical Publications)
                                 Algorithms are relatively easy to understand from Nirali.
                                 Techmax would not be good choice for DAA.






Syllabus for Computer Engineering.


Unit I
Asymptotic notations, necessary mathematical foundation, introduction to Algorithm, Algorithm specifications, Performance analysis, Review of proof techniques: Contradiction and Mathematical induction, Solving Recurrence Equations. Introduction to NP-Hard And NP-Complete Problems, Divide And Conquer And Greedy Strategy, Performance analysis of Algorithmic Strategies Divide and Conquer: General Strategy, Exponentiation, Quick Sort and Merge Sort. Greedy Method: General Strategy, Knapsack problem, Job sequencing with Deadlines, Optimal merge patterns, Minimal Spanning Trees and Dijkstra's algorithm.


Unit II
Dynamic Programming, Study of different ways to implement Knapsack Problem. Implementation of OBST, Traveling Salesperson Problem. General Strategy, Multistage graphs, OBST, 0/1 Knapsack, Traveling Salesperson Problem, Flow Shop Scheduling.
6 Unit III Backtracking: General Strategy, 8 Queen's problem, Graph Coloring, Hamiltonian Cycles, 0/1 Knapsack. Branch and Bound: General Strategy, 0/1 Knapsack, Traveling Salesperson Problem. Design of N Queen's problem, Hamiltonian Cycles


Unit IV
Basic Concepts: Non deterministic algorithms, The classes NP Hard and NP Complete, Cook's Theorem, NP Hard graph problems: Clique Decision problem, Node cover Decision problem, Chromatic number decision problem, Directed Hamiltonian Cycle Problem, TSP Decision problem, AND/OR Graph decision problem, NP-Hard Scheduling problems: Scheduling Identical processors, Flow shop scheduling, Job shop scheduling. NP-Hard Scheduling. Study of NP-Hard and NP-COMPLETE problems. Solving NP-COMPLETE problem.


Unit V
Parallel Algorithms, Study of different graph problems. Implementation of different sorting problems on multiprocessor system. Computational Model, Basic Techniques and Algorithms, Complete Binary Tree, Pointer Doubling, Prefix Computation, Selection, Merging, Sorting, Graph Problems.


Unit VI
Case Studies of Algorithmic Designs & Applications, Implementation of Huffman Problem. Deadlock detection and avoidance implementation. Image edge detection algorithms, Resource allocation algorithm with deadlock avoidance, Heuristic search algorithm, Coding theory algorithm (Huffman coding), Sorting & Convex hulls algorithm. Review and interactive discussions on home tutorials, classroom tutorials and students presentation. Review of recent advances in the subject




Syllabus for IT Engineering



Unit I Introduction 
Analysis of Algorithm Efficiency:- Analysis framework – Asymptotic notations – Analysis of Non-recursive and recursive algorithms. Amortized Analysis, Writing characteristic Polynomial equations, Solving Recurrence Equations, Proof Techniques: by Contradiction, by Mathematical Induction, direct proofs, proof by counterexample, proof by contraposition.


Unit II Divide and Conquer and The Greedy Method 
Characteristic; Analysis Methodology:- Merge sort – Quick Sort – Binary search – Large integer Multiplication and Strassen’s Matrix multiplicationclosest pair and convex Hull problems The Greedy Method : General characteristics of greedy algorithms, Prim’s and kruskal’s Algorithms, Dijkstra’s Algorithm, Huffman Trees.


Unit III Dynamic Programming
General strategy, Principle of optimality, Warshall’s and Floyd’s Algorithm – Optimal Binary Search Trees – knapsack Problem 


Unit IV Backtracking
General method— Recursive backtracking algorithm, iterative backtracking method. 8-queens problem, sum of subsets and Graph coloring, Hamiltonian cycle and Knapsack Problem.


Unit V Branch-Bound 
The method, Least Cost Search, FIFO branch and bound, LC branch and bound. 0/1 Kanpsack problem –LC branch and bound and FIFO branch and bound solution. Traveling sales person problem.


Unit VI NP-Hard and NP-Complete Problems
Basic concepts, Non deterministic Algorithms, The classes of NP hard and NP complete, Cooks Theorem.
NP-Complete problems- Satisfiability problem, vertex cover problem. NP-Hard problems-graph, scheduling, code generation problems, Simplified NP hard Problems.




Books for Download


Fundamentals of Computer Algorithms



(Software to view DJVU Files)






Introduction to Algorithms - Cormen





-------------------------------------------------

Video Lectures



Introduction to Algorithms ( MIT)



Dynamic Programming , Knapsack




Binary, Selection Sort Analysis



Average Case Analysis of Quick Sort



Quick Sort


Bubble Sort - Analysis


=============================

Thursday, November 24, 2011

Waterfall Model - Software Engineering TE[Comp&IT] - Sem 5/ Sem 6

                                 ( Download as PDF )

Waterfall Model

     Waterfall approach was first Process Model to be introduced and followed widely in Software Engineering to ensure success of the project. In "The Waterfall" approach, the whole process of software development is divided into separate process phases.



Overview

Waterfall development isn't new -- it's been around since 1970 -- but most developers still only have a vague idea of what it means. Essentially, it's a framework for software development in which development proceeds sequentially through a series of phases, starting with system requirements analysis and leading up to product release and maintenance . Feedback loops exist between each phase, so that as new information is uncovered or problems are discovered, it is possible to "go back" aphase and make appropriate modification. Progress "flows" from onestage to the next, much like the waterfall that gives the model its name.
The phases in Waterfall model are: 


Requirement Specifications phase
Software Design
Implementation
Testing
Deployment
Maintenance.
waterfall model


The stages of "The Waterfall Model" are:

Requirement Analysis & Definition:

    All possible requirements of the system to be developed are captured in this phase. Requirements are set of functionalities and constraints that the end-user (who will be using the system) expects from the system. The requirements are gathered from the end-user by consultation, these requirements are analyzed for their validity and the possibility of incorporating the requirements in the system to be development is also studied. Finally, a Requirement Specification document is created which serves the purpose of guideline for the next phase of the model.


System & Software Design:
Before a starting for actual coding, it is highly important to understand what we are going to create and what it should look like? The requirement specifications from first phase are studied in this phase and system design is prepared. System Design helps in specifying hardware and system requirements and also helps in defining overall system architecture. The system design specifications serve as input for the next phase of the model.

Implementation & Unit Testing

On receiving system design documents, the work is divided in modules/units and actual coding is started. The system is first developed in small programs called units, which are integrated in the next phase. Each unit is developed and tested for its functionality; this is referred to as Unit Testing. Unit testing mainly verifies if the modules/units meet their specifications.

Integration & System Testing

As specified above, the system is first divided in units which are developed and tested for their functionalities. These units are integrated into a complete system during Integration phase and tested to check if all modules/units coordinate between each other and the system as a whole behaves as per the specifications. After successfully testing the software, it is delivered to the customer.

Operations & Maintenance

This phase of "The Waterfall Model" is virtually never ending phase (Very long). Generally, problems with the system developed (which are not found during the development life cycle) come up after its practical use starts, so the issues related to the system are solved after deployment of the system. Not all the problems come in picture directly but they arise time to time and needs to be solved; hence this process is referred as Maintenance.


Advantages and Disadvantages


Advantages

The waterfall model, as described above, offers numerousadvantages for software developers. First, the staged development cycleenforces discipline: every phase has a defined start and end point, andprogress can be conclusively identified (through the use of milestones) by bothvendor and client. The emphasis on requirements and design before writing asingle line of code ensures minimal wastage of time and effort and reduces therisk of schedule slippage, or of customer expectations not being met.
Getting the requirements and design out of the way firstalso improves quality; it's much easier to catch and correct possible flaws atthe design stage than at the testing stage, after all the components have beenintegrated and tracking down specific errors is more complex. Finally, becausethe first two phases end in the production of a formal specification, thewaterfall model can aid efficient knowledge transfer when team members aredispersed in different locations.

Disadvantages

Despite the seemingly obvious advantages, the waterfallmodel has come in for a fair share of criticism in recent times. The most prominent criticism revolves around the fact that very often, customers don'treally know what they want up-front; rather, what they want emerges out ofrepeated two-way interactions over the course of the project. In thissituation, the waterfall model, with its emphasis on up-front requirementscapture and design, is seen as somewhat unrealistic and unsuitable for thevagaries of the real world. Further, given the uncertain nature of customer needs, estimating time and costs with any degree of accuracy (as the model suggests) is often extremely difficult. In general, therefore, the model is recommended for use only in projects which are relatively stable and wherecustomer needs can be clearly identified at an early stage.
Another criticism revolves around the model's implicitassumption that designs can be feasibly translated into real products; this sometimes runs into roadblocks when developers actually begin implementation.Often, designs that look feasible on paper turn out to be expensive ordifficult in practice, requiring a re-design and hence destroying the clear distinctions between phases of the traditional waterfall model. Some criticism salso center on the fact that the waterfall model implies a clear division of labor between, say, "designers", "programmers" and"testers"; in reality, such a division of labor in most software firms is neither realistic nor efficient.

Customer needs

While the model does have critics, it still remains usefulfor certain types of projects and can, when properly implemented, produce significant cost and time savings. Whether you should use it or not dependslargely on how well you believe you understand your customer's needs, and howmuch volatility you expect in those needs as the project progresses. It's worth nothing that for more volatile projects, other frameworks exists for thinking about project management, notably the so-called spiral model...but that's a story for another day!


=======================================

Video Lectures





Overview of Different Models



Waterfall vs Agile


========================================

Thursday, July 28, 2011

Learn Java with Video tutorials

Introduction

      Java is an object-oriented language similar to C++, but simplified to eliminate language features that cause common programming errors. Java is a general purpose programming language with a number of features that make the language well suited for use on the World Wide Web. Small Java applications are called Java applets and can be downloaded from a Web server and run on your computer by a Java-compatible Web browser, such as Netscape Navigator or Microsoft Internet Explorer. 

What is Java technology and why do I need it?

Java is a programming language and computing platform first released by Sun Microsystems in 1995. It is the underlying technology that powers state-of-the-art programs including utilities, games, and business applications. Java runs on more than 850 million personal computers worldwide, and on billions of devices worldwide, including mobile and TV devices.
Why do I need Java?
There are lots of applications and websites that won't work unless you have Java installed, and more are created every day. Java is fast, secure, and reliable. From laptops to datacenters, game consoles to scientific supercomputers, cell phones to the Internet, Java is everywhere!
Is Java free to download?
Yes, Java is free to download. Get the latest version at http://java.com.
If you are building an embedded or consumer device and would like to include Java, please contact Oracle for more information on including Java in your device.
Why should I upgrade to the latest Java version?
The latest Java version contains important enhancements to improve performance, stability and security of the Java applications that run on your machine. Installing this free update will ensure that your Java applications continue to run safely and efficiently.


Links to the video series on Java Programming Basics : Special thanks to www.pucomp.org for this Series. Java is a powerful, cross-platform, object-oriented programming language suitable for writing anything from a distributed application that runs on a corporate network to a database-driven web-site to host your personal photo gallery.


Below are the links to the series of videos on Java concepts (complete guide)

1 Java Programming basics-Lecture 1Java Programming 48m 11s
2 Java Programming basics-Lecture 2 Java Programming 42m 28s
3 Java Programming basics-Lecture 3 Java Programming 48m 52s
4 Java Programming basics-Lecture 4 Java Programming 50m 59s
5 Java Programming basics-Lecture 5 Java Programming 50m 57s
6 Java Programming basics-Lecture 6 Java Programming 42m 55s
7 Java Programming basics-Lecture 7 Java Programming 47m 12s
8 Java Programming basics-Lecture 8 Java Programming 49m 29s
9 Java Programming basics-Lecture 9 Java Programming 48m 47s
10 Java Programming basics-Lecture 10 Java Programming 47m 09s

11 Java Programming basics-Lecture 11 Java Programming 49m 06s

12 Java Programming basics-Lecture 12 Java Programming 37m 29s

13 Java Programming basics-Lecture 13 Java Programming 48m 11s

14 Java Programming basics-Lecture 14 Java Programming 50m 09s

15 Java Programming basics-Lecture 15 Java Programming 48m 14s

16 Java Programming basics-Lecture 16 Java Programming 49m 12s

17 Java Programming basics-Lecture 17 Java Programming 51m 27s

18 Java Programming basics-Lecture 18 Java Programming 50m 37s

19 Java Programming basics-Lecture 19 Java Programming 49m 43s

20 Java Programming basics-Lecture 20 Java Programming 44m 24s

21 Java Programming basics-Lecture 21 Java Programming 49m 27s

22 Java Programming basics-Lecture 22 Java Programming 50m 20s

23 Java Programming basics-Lecture 23 Java Programming 45m 55s

24 Java Programming basics-Lecture 24 Java Programming 50m 30s

25 Java Programming basics-Lecture 25 Java Programming 48m 32s



Video Lectures on Java from NPTEL (IIT)
Introduction to Java (Installation of JDK)

Introduction to Swing



Interfaces
 Exceptions
AWT  

Servlets Basics
 

Writing Servlets

Creating Servlets using Netbeans


Java Applets (Part 1)



Java Applets (Part 2)

Client Server Programming (Java)