DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • The RISC-V Architecture
  • Far Memory Unleashed: What Is Far Memory?
  • Best Practices for Exchange Server 2019 Storage
  • How to Move System Databases to Different Locations in SQL Server on Linux

Trending

  • How the Go Runtime Preempts Goroutines for Efficient Concurrency
  • Transforming AI-Driven Data Analytics with DeepSeek: A New Era of Intelligent Insights
  • Why High-Performance AI/ML Is Essential in Modern Cybersecurity
  • Docker Model Runner: Streamlining AI Deployment for Developers
  1. DZone
  2. Data Engineering
  3. Databases
  4. What Is Segmentation in Operating System?

What Is Segmentation in Operating System?

Read this article to learn how segmentation creates segments for the user program, and see an example of how it can reduce CPU overhead.

By 
Mahesh Sharma user avatar
Mahesh Sharma
·
Sep. 09, 21 · Analysis
Likes (3)
Comment
Save
Tweet
Share
12.3K Views

Join the DZone community and get the full member experience.

Join For Free

The idea of segmentation In OS is similar in function to paging, which is used to manage memory. Segmentation is a way to divide the user program and data into segments. Segmentation and paging are two different things. Each page in paging has a fixed size, while segments have a variable size.

Segmentation maps the user's view onto actual physical memory. We will briefly discuss segmentation and its workflow in the next section. We will also discuss segmentation using an example and conclude the discussion with some advantages and disadvantages.

Segmentation in OS

What Is Segmentation in OS?

Segmentation is used to manage memory. The user's view is plotted onto physical memory. Segmentation is where the user program is broken down into the number of segments that each segment is of variable size.

Segmentation can be described as dynamic partitioning where the segments that are being divided are of variable sizes. These segments do not need to be in the same memory. Segmentation doesn't cause internal fragmentation, but it can create external fragmentation.

A program can be divided into segments according to the user's perspective. The main method has a set of objects, methods, arrays, and procedures. It also includes templates, global variables, and other items. These modules or data elements refer to the segments that the user refers to by their name. They are indifferent as to what address the modules or elements are stored in their memory. The user doesn't have to worry about the order in which the data elements or modules are stored in memory.

Each segment in the user program is variable in length.  The purpose of each segment is what determines its length. In logical addressing, elements within a segment are identified using their offset value, which starts at the beginning of the segment.  Two entities know the logical address for a segment:  segment name and the offset.  Each segment created by a user program is numbered as the segment number instead of the segment name. Now, the logical address is composed of two tuples.

Segmentation Implementation

Let's now look at the implementation of segmentation.  Segmentation is a way to divide a user program into a number of segments.  A segment can be identified by two components: a segment name and a segment offset.

This section will show you how the two-dimensional address is mapped onto one-dimensional physical memories. As we have a page table for paging, we also have a segment table for segmentation.

Segmentation Table

The segmentation table contains two entries:  the segment base address and segment limit.  The segment base address denotes the address at which the segment is stored in memory.  The segment limit denotes the length and width of the segment.

As you can see in the above figure, the CPU calls for a segment and provides a two-dimensional address. The segment number (or segment name) and its offset are "d".

The segment number will allow you to get two additional details about the segment number in the segment table:  segments base address and its limit. The offset provided by the CPU is checked to see if it's between 0 and the limit for called segments.  If yes, then the offset is added to the base address of called segments to retrieve the physical address.  If the offset does not verify the condition, the operating system will throw an addressing error.  The logical address attempts to extend the segment limit.

Advantages and Disadvantages of Segmentation

Segmentation has many advantages:

  • Segmentation is closer to the programmer’s view of physical memories.
  • Segmentation is a way to prevent internal fragmentation.
  • Segmentation reduces CPU overhead because it contains an entire module at once.

Segmentation's disadvantages:

  • External fragmentation can be caused by segmentation.

The Key Takeaways

  • Segmentation is used to manage memory.
  • Segmentation is very similar to how the user views physical memory.
  • Segmentation is a method of dividing a user program into segments with variable lengths. The purpose of each segment will determine its length.

Segmentation is an array that contains the base address and the limits.  The base address denotes where a particular segment is located in the physical memory, while the limit denotes how long it is.

External fragmentation can be caused by segmentation.

operating system Base address Memory (storage engine) Database

Opinions expressed by DZone contributors are their own.

Related

  • The RISC-V Architecture
  • Far Memory Unleashed: What Is Far Memory?
  • Best Practices for Exchange Server 2019 Storage
  • How to Move System Databases to Different Locations in SQL Server on Linux

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!