Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Parallel, and Distributed Systems ANS:-: - Explain The Distinctions Among Concurrent

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

• Explain the distinctions among concurrent,

parallel, and distributed systems


ANS:-
Parallel System :-
Working on the project chronologically will be a very
difficult and time-consuming task. So instead of only one version,
multiple versions of the project are created. Each of the versions
includes unique features derived from the previous versions. The
developers can work on these versions simultaneously before
merging them with the final version. This approach is generally
referred to as a parallel system.
Parallel systems allows multiple development teams to work
simultaneously on software so that the time required to develop a
software system can be minimized.

Distributed system:
A distributed development system is responsible for
planning, designing, building, testing, and maintaining the
software with decentralized teams, located in different physical
workspaces. These teams collaborate and communicate with each
other by using internet-based collaboration tools and platforms to
build software applications.
Communication is done with emails, the internet and other
long-distance communication mediums. Distributed systems are
largely pioneered by the open-source community.

Concurrent system:
Most of the software development processes involve a
series of development phases, such as requirement gathering,
prototyping, product design and testing. It is inevitable to go back
to earlier phases to make changes or work on the later phases since
their phases are interrelated. This type of model here multiple phases
are performed concurrently provided they are no longer dependent on
each other is known as a concurrent system.
A concurrent software development system is a system in
which different stages of product development are executed
simultaneously, rather than in a linear or sequential manner. It
reduces overall development time and provides a faster version
of the product in the market.

• What is a race condition? What is


synchronization?
ANS :-
Synchronization :-
Process Synchronization is the coordination of execution of
multiple processes in a multi-process system to ensure that they
access shared resources in a controlled and predictable manner.
It aims to resolve the problem of race conditions and other
synchronization issues in a concurrent system.
The main objective of process synchronization is to ensure
that multiple processes access shared resources without interfering
with each other and to prevent the possibility of inconsistent data
due to concurrent access.
To achieve this, various synchronization techniques such as
semaphores, monitors, and critical sections are used.
Race Condition :-
When more than one process is executing the same code or
accessing the same memory or any shared variable in that
condition there is a possibility that the output or the value of the
shared variable is wrong so for that all the processes doing the race
to say that my output is correct this condition known as a race
condition.
Several processes access and process the manipulations over
the same data concurrently, and then the outcome depends on the
particular order in which the access takes place.
A race condition is a situation that may occur inside a critical
section. This happens when the result of multiple thread execution
in the critical section differs according to the order in which the
threads execute.
Race conditions in critical sections can be avoided if the
critical section is treated as an atomic instruction. Also, proper
thread synchronization using locks or atomic variables can prevent
race conditions.

• What is a context switch? What is Pre-emption?


ANS:-
Context Switch :-
Context switching in an operating system involves saving the
context or state of a running process so that it can be restored later,
and then loading the context or state of another. process and run it.
Context Switching refers to the process/method used by the
system to change the process from one state to another using the
CPUs present in the system to perform its job.
Context switching enables all processes to share a single
CPU to finish their execution and store the status of the system’s
tasks.
The execution of the process begins at the same place where
there is a conflict when the process is reloaded into the system.

Pre-emption:-
Pre-emption is a form of multitasking in which the scheduler
interrupts and suspends a currently running task in order to resume
a previously suspended task. This activity takes place on just about
every operating system available.
Pre-emption involves the use of an interrupt mechanism,
which suspends the currently executing thread and then invokes
the scheduler to determine which thread should be executed next,
allowing all threads to receive some amount of processor time.
The time alloted for a thread to run in a preemptive
multitasking system is called the time slice or quantum time.

• Explain the coherence problem for


multiprocessor caches.
ANS:-
In a multiprocessor system, data inconsistency may occur
among adjacent levels or within the same level of the memory
hierarchy. For example, the cache and the main memory may have
inconsistent copies of the same object.
As multiple processors operate in parallel, and independently
multiple caches may possess different copies of the same memory
block, this creates cache coherence problem.
Cache coherence schemes help to avoid this problem by
maintaining a uniform state for each cached block of data.
Let X be an element of shared data which has been
referenced by two processors, P1 and P2. In the beginning, three
copies of X are consistent. If the processor P1 writes a new data
X1 into the cache, by using write-through policy, the same copy
will be written immediately into the shared memory. In this case,
inconsistency occurs between cache memory and the main
memory.
When a write-back policy is used, the main memory will be
updated when the modified data in the cache is replaced or
invalidated.
• Briefly describe the process of resolution in logic
programming
ANS:-
Logic programming is generally used and adopted to prove
any mathematical theorem and for solving the geometrical terms
and other mathematical terms. Thus, it plays a significant role in
automated theorem proving.
In the logical programming, theorem has been stated by the
programmer or the end user and it is required to find a collection of
rules and axioms by attempting the language implementation.
Thus, logic programming is an approach of finding and
providing the solution of the problem or implied goal by the
system by stating or declaring the state properties of the problem.
Prolog is one of the most popular and extensively used logic
programming languages.

• What is a unification? Why is it important in logic


programming?
ANS:-
Unification is a concept that is linked to logic programming.
Unification, as the name suggests, is a binding logic between two
or more variables.
The goal is to make two expressions look identical by using
substitution. For simple logic, we use first-order unification, and to
unify typed lambda terms, we use higher-order unification.
It is used in logical programming, where the aim is to make
expressions look identical to each other and to make them
identical, we generally use substitution. Substitution means
replacing one variable with another term.
Here are some examples:
Statement: X * Y
Substitution (x as a and y as b)
a * Y ………. (i)
X * b ……… (ii)
a * b …….. (iii)
Need of Unification :-
It is the most fundamental concept regarding logical
programming in computer science. The algorithm plays a key role
in specializing in the operation, equations, or rules of the data.
For a basic understanding, if we need to combine two simple
but overlapping equations or rules, we can easily combine them by
performing a substitution, which is nothing but unification.
unification can be used for type inference, where we can see
that substituting only the same variable type is possible, not on the
different type;
hence it removes redundancy in algorithms. Data types are
significantly important in computer science for defining different
variables.

• What are clauses, terms, and structures in Prolog?


What are facts, rules, and queries?
Clauses:-
Clauses are the structural elements of a program. A Prolog
programmer develops a program by writing a collection of clauses
in a text file. The programmer then uses the consult command,
specifying the name of the text file, to load the clauses into the
Prolog environment.
The are two types of clauses -
1 . facts
2 . rules.

Terms:-
Prolog programs are constructed from terms. A term is either
a constant, a structure or a variable.

Structures:-
Structures, also known as compound terms, consist of a
functor (name) and a number of arguments (other terms). The
number of arguments a structure has is known as its arity. A
structure is defined in Prolog by specifying its functor followed by
its arguments separated by commas and enclosed in round
brackets. Examples of valid Prolog syntax for defining structures
are: p(), p(a) and p(X, a, q(1,2)).
A special type of structure is the list.

Facts:-
A fact is an atom or structure followed by a full stop.
Examples of valid Prolog syntax for defining facts are: cold.,
male(homer). and father(homer,bart)..

Rules:-
A rule consists of a head and a body. The head and body are
separated by a :- and followed by full stop. If the body of a clause
is true then the head of the clause is true. Examples of valid Prolog
syntax for defining rules are: bigger(X,Y) :- X > Y. and
parents(F,M,C) :- father(F,C), mother(M,C).

Queries:-
Queries allow us to ask questions of the Prolog
environment. The Prolog environment will try to answer the
query by using the facts and rules that have been loaded into it.
Prolog queries start with a ?- and end with a full stop. When using
the console there is no need to type in the ?- as it is automatically
added for you. Examples of valid Prolog syntax for specifying a query
are: ?- 1 < 2. and ?- father(F,C).
• Difference between forward and backward
chaining.

Q 2,6,10 Remaining

You might also like