APEX INSTITUTE OF
TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE &
ENGINEERING
OPERATING SYSTEM
Faculty: Ms. Anudeep Kaur(E16380)
Lecture 2 DISCOVER . LEARN .
EMPOWER 1
Table of Contents
Introduction to Atomic Transactions
Characteristics of Atomic Transactions
Role of Atomic Transactions in Operating Systems
Importance/Advantages of Atomic Transactions in Operating Systems
Use Cases in Operating Systems
Key Components of Atomic Transactions
What is a Distributed Operating System?
Limitations of Atomic Transactions in Distributed Systems
COURSE OUTCOME
CO1 Remember and understand fundamental functions of operating system.
CO2 Understand Process and Disk scheduling algorithms and apply the best scheduling
algorithm for a given problem instance.
CO3 Apply an algorithm for process scheduling, deadlock avoidance and file management.
CO4 Identify and analyze memory management techniques and apply them for memory
management related problems.
CO5 Analyze the performance of process management, resource management and
deadlock management techniques and apply the best methods for a given problem
instance.
UNIT-1 SYLLABUS
Unit-1 Contact Hours: 15 HOURS
Operating System Introduction to Operating Systems, Operating System Structure, Main Functions and
characteristics of Operating Systems, Types of Operating Systems, System calls, Types of
Overview system calls, System programs, Reentrant Kernels, Monolithic and Microkernel Systems
Process Process Concept, Process Control Block, Process Scheduling, Threads, CPU Scheduling:
Preemptive/Non-Preemptive Scheduling, Scheduling Criteria, Scheduling Algorithms
Management (FCFS, SJF, RR), Priority, real-time scheduling.
Semaphores Inter Process Communication, Semaphores, Atomic Transactions, Semaphore
Implementation-1, Semaphore Implementation-2
Introduction to Atomic Transactions
Atomic transactions are a fundamental concept in operating systems, ensuring the integrity and
reliability of data. These transactions are designed to be indivisible, consistent, and secure,
making them crucial for maintaining the stability of complex software systems.
Defination:
In the dynamic OS environment, data consistency and reliability are critical. One of the
main mechanisms that help this stability is so-called atomic transactions. Atomic
transactions are key in maintaining the integrity of data to ensure that operations on that
data occur either completely or not at all.
Characteristics of Atomic Transactions
1 Indivisibility 2 Consistency
Atomic transactions cannot be Atomic transactions ensure that the
broken down into smaller parts; they system remains in a valid state before
must be executed in their entirety or and after the transaction is executed.
not at all.
3 Isolation 4 Durability
Atomic transactions are isolated from The effects of a successful atomic
other concurrent transactions, transaction are permanent and
preventing interference and ensuring cannot be undone, even in the event
data integrity. of a system failure.
Role of Atomic Transactions in Operating Systems
Atomic Transactions
Atomic transactions in a database system are a fundamental mechanism to ensure data integrity and consistency. The ACID
properties (Atomicity, Consistency, Isolation, Durability) are central to the concept of atomic transactions:
1.Atomicity: Ensures that a transaction is treated as a single, indivisible unit of work. All operations within a transaction must
complete successfully; if any operation fails, the entire transaction is rolled back, leaving the system unchanged.
2.Consistency: Guarantees that a transaction transforms the database from one valid state to another, preserving database
invariants (e.g., integrity constraints, business rules).
3.Isolation: Ensures that transactions are executed independently of one another. The intermediate state of a transaction is not
visible to other transactions.
4.Durability: Ensures that once a transaction has been committed, its changes are permanent, even in the event of a system
failure.
Importance/Advantages of Atomic Transactions in Operating Systems
1.Consistency: Ensures that the system remains in a consistent state even in the presence of failures. If a
transaction cannot be completed, the system can roll back to its previous state, maintaining consistency.
2.Isolation: Ensures that transactions are isolated from each other. This means that the operations in one
transaction do not interfere with those in another, which is vital in multi-user environments to prevent data
corruption.
3.Durability: Guarantees that once a transaction has been committed, it will remain so, even in the event of a
system failure. This is essential for data integrity and reliability.
4. Simplified Programming Model: By abstracting the complexities of error handling and consistency
management, atomic transactions simplify the development process. Developers can focus on implementing
business logic without worrying about intricate failure scenarios.
5. Error Handling: Atomic transactions provide robust error handling through rollback mechanisms. If an error
occurs during a transaction, the system can revert to the previous consistent state, ensuring that partial updates
do not corrupt the data.
Use Cases in Operating Systems
1.File Systems: Atomic transactions are used to ensure that file operations (such as write, delete, or move) are
completed successfully. If a file operation fails, the system can revert to the previous state, preventing data loss or
corruption.
2.Database Management: Operating systems often interact with database management systems (DBMS) which use
atomic transactions to ensure data integrity. For example, in a banking system, a transaction involving the transfer
of money from one account to another must be atomic to ensure that money is neither created nor lost during the
process.
3.Concurrency Control: In systems with multiple processes or threads, atomic transactions help manage access to
shared resources. This prevents race conditions and ensures that only one transaction can modify a resource at a
time.
4.Recovery Mechanisms: Atomic transactions play a critical role in system recovery. If a system crashes, the
recovery mechanism uses the logs of transactions to bring the system back to a consistent state.
Key Components of Atomic Transactions
1.Begin: Marks the start of a transaction.
2.Execute: Executes a series of operations within the transaction.
3.Commit: Marks the successful completion of the transaction. All changes made during the
transaction are saved.
4.Rollback: If an error occurs, the transaction is rolled back to the state before the transaction
began, discarding all changes.
What is a Distributed Operating
System?
A Distributed Operating System refers to a model in which applications run on multiple
interconnected computers, offering enhanced communication and integration
capabilities compared to a network operating system.
In a Distributed Operating System, multiple
CPUs are utilized, but for end-users, it
appears as a typical centralized operating
system. It enables the sharing of various
resources such as CPUs, disks, network
interfaces, nodes, and computers across
different sites, thereby expanding the
available data within the entire system.
Limitations of Atomic Transactions in Distributed Systems
1.Performance Overhead: Distributed atomic transactions require synchronization across multiple nodes, which involves
significant communication overhead. This can lead to increased latency and reduced overall system performance.
2.Complexity in Coordination: Ensuring atomicity across multiple nodes is complex. Coordinating transactions, especially in the
presence of network partitions or node failures, requires sophisticated protocols such as two-phase commit (2PC) or three-
phase commit (3PC).
3.Scalability Issues: As the number of nodes increases, the overhead of coordinating atomic transactions also increases. This
can create performance bottlenecks, limiting the system’s scalability.
4.Resource Contention and Deadlocks: Distributed transactions often involve locking resources on multiple nodes. This can
lead to contention, and in the worst cases, deadlocks, where transactions wait indefinitely for resources held by each other.
5.Failure Handling Complexity: Handling failures in a distributed environment is challenging. Network partitions, node failures,
and message losses can complicate the transaction management process, making it difficult to maintain consistency and
atomicity.
6.Limited Flexibility: The strict requirements of atomic transactions can be too rigid for some distributed applications that can
tolerate eventual consistency. In such cases, the overhead of maintaining strict atomicity may outweigh its benefits.
Strategies to Overcome These Limitations
1.Optimistic Concurrency Control: Instead of locking resources, use optimistic concurrency control mechanisms
where transactions proceed without locking resources and only check for conflicts at commit time. If conflicts are
detected, transactions are rolled back and retried.
2.Partitioning and Sharding: Divide the database into smaller, independent partitions or shards. Transactions are
limited to a single shard whenever possible, reducing the need for distributed coordination and improving
scalability.
3.Using Distributed Consensus Algorithms: Implement consensus algorithms like Paxos or Raft, which can help in
achieving agreement among distributed nodes more efficiently than traditional commit protocols.
4.Eventual Consistency Models: For applications that can tolerate eventual consistency, use models like BASE
(Basically Available, Soft state, Eventual consistency) instead of ACID. This reduces the strict requirements for
atomicity and improves system performance and availability.
5. Snapshot Isolation: Use snapshot isolation to provide a consistent view of the database to transactions without
locking resources. This can help in reducing contention and improving performance.
6. Adaptive Timeout Mechanisms: Implement adaptive timeout mechanisms to handle deadlocks and reduce the
chances of indefinite waiting. By dynamically adjusting timeout periods based on system load and transaction
patterns, you can minimize the impact of deadlocks.
7. Hybrid Approaches: Combine different consistency models within the same system. For example, use strict
atomic transactions for critical operations and eventual consistency for less critical operations. This allows for better
performance and scalability while maintaining reliability where needed.
8. Log-Based Recovery: Use log-based recovery mechanisms to efficiently handle failures. By maintaining detailed
logs of transactions, the system can quickly roll back to a consistent state in case of failures, minimizing the impact
on performance.
9. Decentralized Coordination: Reduce the reliance on centralized coordination by using decentralized coordination
protocols. This can distribute the load more evenly across nodes and improve the system’s ability to handle larger
scales.
Back Exercise
How do atomic transactions ensure data consistency in a database system? Provide an example.
Explain the role of atomic transactions in a banking application.
How can atomic transactions be used to manage memory allocation and deallocation in an operating
system?
Describe how the ACID properties (Atomicity, Consistency, Isolation, Durability) are maintained in atomic
transactions with an example.
How do atomic transactions contribute to the robustness of an operating system? Provide a detailed
analysis.
Evaluate the impact of atomic transactions on system performance, considering both advantages and overhea
Analyze the challenges of implementing atomic transactions in a distributed system.
E-Video Links
https://www.youtube.com/watch?v=bkSWJJZNgf8&list=PLxCzCOWd
7aiGz9donHRrE9I3Mwn6XdP8p
• https://www.youtube.com/watch?v=vBURTt97EkA&list=PLBlnK6fE
yqRiVhbXDGLXDk_OQAeuVcp2O
• https://nptel.ac.in/courses/106/108/106108101/
.