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 5. Show all posts
Showing posts with label Sem 5. 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:







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, November 17, 2011

Pune University : TE - IT - 2010 Dec : Question Papers




Question Papers for Third Year Engineering  in
 Information Technology :Pune University
     
Subject
Download Link
Software Engineering
Operating Systems
Theory of Computation
Computer Network Technology

Wednesday, September 28, 2011

What is Mutex? - Explanation and Animation

   
     In computer programming, a mutex (mutual exclusion object) is a program object that is created so that multiple program thread can take turns sharing the same resource, such as access to a file. Typically, when a program is started, it creates a mutex for a given resource at the beginning by requesting it from the system and the system returns a unique name or ID for it. After that, any thread needing the resource must use the mutex to lock the resource from other threads while it is using the resource. 
    If the mutex is already locked, a thread needing the resource is typically queued by the system and then given control when the mutex is locked during the new thread's use of the resource). becomes unlocked (when once more, the the mutex is locked during the new thread's use of the resource).
    Semaphore owns the resource ownership whereas mutex doesn't. Means when the semaphore enters the critical section by setting the sem_flag as one but because of some means(lets say dead lock) it gets blocked inside the critical section waiting for another resource,which is being used by another process/thread.So now no other process can enter the  critical section ...almost deadlock..means no other process can unset the sem_flag to zero..=> implies the process which sets the lock/flag has to unlock the flag.No other process/thread has the permission to unlock..


    On the other hand, mutex doesn't own the ownership means even if it gets blocked inside the crtitical region,any other process can enter the critical section. A semaphore post (or basically unlock) can be performed by  a different thread. However, in the case of mutex, it should be unlocked only by the same thread.

 Lets understand how does the Mutual Exclusion works using this animation -



Thursday, July 14, 2011

Operating System - Lecture Notes

Download Operating System Lectures Notes from our portal. The book can be used as a guide to understand the basic concepts of Operating systems and as a guide for Last Minute Revision.

Operating System - Lecture Notes


Thursday, June 30, 2011

Learn the OSI Model - [Data Communications, CNT]


Introduction


Data Communications and Computer Networks are two very important subjects in the curriculum of IT and Computer Engineering. The OSI model is very important concept in both of these subjects. The entire subject is layed down on the foundation of the OSI model.



What is  the OSI Model?


The Open Systems Interconnection model (OSI model) was a product of the Open Systems Interconnection effort at the International Organization for Standardization. It is a way of sub-dividing a communications system into smaller parts called layers. Similar communication functions are grouped into logical layers

 There are 7 layers in the OSI model :






Description of all Layer 


Application Layer
This layer supports application and end-user processes. Communication partners are identified, quality of service is identified, user authentication and privacy are considered, and any constraints on data syntax are identified. Everything at this layer is application-specific. This layer provides application services for file transfers, e-mail, and other network software services. Telnet and FTP are applications that exist entirely in the application level. Tiered application architectures are part of this layer.

Presentation Layer
This layer provides independence from differences in data representation (e.g., encryption) by translating from application to network format, and vice versa. The presentation layer works to transform data into the form that the application layer can accept. This layer formats and encrypts data to be sent across a network, providing freedom from compatibility problems. It is sometimes called the syntax layer.

Session Layer
This layer establishes, manages and terminates connections between applications. The session layer sets up, coordinates, and terminates conversations, exchanges, and dialogues between the applications at each end. It deals with session and connection coordination.

Transport Layer
This layer provides transparent transfer of data between end systems, or hosts, and is responsible for end-to-end error recovery and flow control. It ensures complete data transfer.

Network Layer
This layer provides switching and routing technologies, creating logical paths, known as virtual circuits, for transmitting data from node to node. Routing and forwarding are functions of this layer, as well as addressing, internetworking, error handling,congestion control and packet sequencing.

Data-link Layer
At this layer, data packets are encoded and decoded into bits. It furnishes transmission protocol knowledge and management and handles errors in the physical layer, flow control and frame synchronization. The data link layer is divided into two sub layers:

·         The Media Access Control (MAC) layer
The MAC sub layer controls how a computer on the network gains access  to the data and permission to  transmit it.

       ·         The Logical Link Control (LLC) layer.
 The LLC layer controls framesynchronization, flow control and error checking.

Physical Layer
This layer conveys the bit stream - electrical impulse, light or radio signal -- through the network at the electrical and mechanical level. It provides the hardware means of sending and receiving data on a carrier, including defining cables, cards and physical aspects. Fast Ethernet, RS232, and ATM are protocols with physical layer components.

Video Demonstration


 Learn how an message passes through the OSI model using this video:
A complete self-explanatory video on the 7 layers of OSI model and its real-time application. It's an interactive video , so make sure that you click on continue buttons once understand the description at each step.








Monday, June 20, 2011

Software Engineering : 5th SEM [I.T.] & 6th SEM [COMP]

This is a subject which may sound simple and interesting but is not what it actually seems to be. You , will  definitely get bugged up studying this subject. A total theoretical subject which will definitely consume your sufficient quality time. You will need to by-heart many concepts in this subject to actually reproduce them during the exams. It is a tough job for any Engineer to actually mug up.
But, one good thing about this subject is that : the subject is really scoring, provided you give appropriate answers. Scoring 70+ is not difficult in this subject.


 Books: Among our local authors , please don't refer Techmax.....instead prefer Technical. The technical's book is almost copied from the reference Book by Roger Pressman. The book will suffice to score above 70.


Among foreign authors : Software Engineering - Roger Pressman -> is the best book to learn Software Engineering. This book is of great use to you in BE also, as you can refer this book for the subject STQA i.e. Software Testing and Quality Assurance.


 Download E-Books :


 

Download Now (Direct Download)


Software Engineering Techniques 
- Design for Quality
 K. Sacha


Analysis of the Subject:
Unit 1 : Simple and easy to learn when compared to the other units. You can almost predict the important topics from exam point of view.

Unit 2 : Interesting to learn,...you can compare the topics in the unit to actual tasks in real life and easily learn this unit using examples.


Unit 3 : Lengthy... but still you  can cope with this unit....its not difficult to learn.


Unit 4 : This is the most time consuming and confusing unit ...i found in the subject....all concepts are new and confusing.


Unit 5 :  Time consuming unit...but still, it is much better than the 4th unit.


Unit 6 : This is the easiest unit in tthe 2nd section of this subject.Interesting ..but its really time consuming.




You can learn Software Engineering by using the PPT's designed by other popular universities