<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Isuruni Rathnayaka on Medium]]></title>
        <description><![CDATA[Stories by Isuruni Rathnayaka on Medium]]></description>
        <link>https://medium.com/@isu-rathnayaka?source=rss-dc90ed1bd5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*01OFEWSxH1yO2uo6XtlkmQ.png</url>
            <title>Stories by Isuruni Rathnayaka on Medium</title>
            <link>https://medium.com/@isu-rathnayaka?source=rss-dc90ed1bd5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 18:55:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@isu-rathnayaka/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Risk Management as a Project Manager: Turning Uncertainty into Informed Action]]></title>
            <link>https://isu-rathnayaka.medium.com/risk-management-as-a-project-manager-turning-uncertainty-into-informed-action-398a1075b5fd?source=rss-dc90ed1bd5------2</link>
            <guid isPermaLink="false">https://medium.com/p/398a1075b5fd</guid>
            <category><![CDATA[opportunity]]></category>
            <category><![CDATA[threat]]></category>
            <category><![CDATA[project-management]]></category>
            <category><![CDATA[risk-management]]></category>
            <category><![CDATA[risk]]></category>
            <dc:creator><![CDATA[Isuruni Rathnayaka]]></dc:creator>
            <pubDate>Tue, 10 Feb 2026 19:01:34 GMT</pubDate>
            <atom:updated>2026-02-10T19:01:34.595Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>“Projects don’t fail because risks exist. They fail because risks are discovered too late.”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h9d7xSbDBR7NhQzS.jpg" /></figure><p>Every project starts with a plan.<br>But every successful project survives reality.</p><p>To explore what real risk management looks like in practice, let’s ground this discussion in a single example and use it throughout.</p><p>As Project Managers, we plan timelines, allocate budgets, assign people, and define success. But somewhere between kickoff and delivery, reality intervenes, a key team member resigns, a vendor delays a critical component, a new regulation appears, or a competitor releases a similar product before us.</p><p>We operate in environments filled with uncertainty — changing requirements, human factors, technical complexity, market movement, and external dependencies.</p><p>This is where <strong>risk management</strong> stops being a theory and starts being one of the most valuable skills a Project Manager can have. Risk management is the discipline that allows us to move forward <strong>without the illusion of certainty</strong>.</p><p>Time to explore risk management through a simple example and then break down the concepts behind it.</p><h3>The project behind the concepts</h3><p>Imagine you are managing the development of a <strong>mobile learning application</strong>. The scope includes video content, assessments, subscriptions, and analytics. The business goal is not only to launch an app, but to create a scalable learning platform that can grow rapidly.</p><p>On paper, the plan is solid. <br>At the kickoff meeting, everything looks achievable. But beneath the surface, many uncertainties exist:</p><ul><li>Will the payment gateway approval take longer than expected?</li><li>Will the content team deliver on time?</li><li>What if app store review policies change?</li><li>What if a team member suddenly gets sick?</li><li>The marketing team is pushing for features not originally planned.</li></ul><p>None of these are problems yet.<br>But all of these are <strong>risks</strong>.</p><p>A risk is not just a problem.<br>A risk is an <strong>uncertain event or condition that, if it occurs, will have an effect on project objectives.</strong> That effect can be <strong>negative (a threat)</strong> or <strong>positive (an opportunity). <br></strong>This is the point many teams miss. Risk is not only about what might go wrong. It is also about what might go exceptionally right.</p><p>Risk management is not about eliminating uncertainty.<br>It is about <strong>understanding it, preparing for it, and responding intelligently.</strong></p><h3>From uncertainty to control: the five-step risk management cycle</h3><blockquote>Risk management is not an event. It is a system.</blockquote><p>Risks do not arrive neatly labeled. They surface through assumptions, delays, discussions, stakeholder concerns, and technical experiments. Managing them effectively requires more than noticing their existence. It requires a structured, repeatable process.</p><p>Professional risk management follows a disciplined flow. In practice, it is not a checklist — it is a loop that runs throughout the project lifecycle.</p><p>Professional risk management in projects moves through five continuous steps: <strong>identification, evaluation and analysis, documentation, control and management, and reporting.</strong> These are not linear stages completed once. They form a living cycle that evolves as the project evolves.</p><h4>Step 1: Identifying risks properly — turning assumptions into visibility</h4><p>The first step is <strong>identifying risks properly.</strong> Risk identification is about deliberately surfacing uncertainty. This goes beyond asking “what can go wrong?” It involves deliberately examining assumptions, dependencies, technologies, people, and external constraints.</p><p>In the early phase of the app project, the team may assume that third-party services will scale, that app store approvals will be quick, and that the content pipeline will flow smoothly. Each assumption hides potential exposure.</p><p>A Project Manager creates structured spaces where these assumptions are challenged, therefore risk identification could involve:</p><p><strong><em>Reviewing past similar projects<br>Running technical spike discussions<br>Interviewing stakeholders<br>Facilitating team brainstorming sessions.</em></strong></p><p>Developers highlight technical fragility. QA highlights testability and environment gaps. Business stakeholders surface regulatory, contractual, and market-driven risks.</p><p>When identified in practice, risks appear at different levels.</p><p><strong><em>1. Task risks (operational or execution-level risks)</em></strong></p><p>These are related to specific activities. They directly affect <strong>individual tasks or components</strong>.</p><p>Examples from our app project can be:</p><ul><li>A developer unfamiliar with a new framework</li><li>Delays in UI designs</li><li>Bugs in the assessment module</li><li>Incomplete requirements for payments</li></ul><p><strong><em>2. Project risks (overall or strategic risks)</em></strong></p><p>These affect the project as a whole.</p><p>Examples for them can be:</p><ul><li>Budget overrun</li><li>Regulatory or compliance changes</li><li>Vendor instability</li><li>Loss of stakeholder support</li><li>Unrealistic deadlines</li></ul><p>The objective is not completeness.<br> The objective is <strong>awareness early enough to influence decisions.</strong></p><blockquote>You cannot manage what you haven’t identified. But identifying alone changes nothing.</blockquote><p>Once risks are visible, they move into <strong>evaluation and analysis.</strong> Here, the Project Manager guides the team to understand how likely each risk is and how strongly it could affect objectives. A possible delay in content delivery may be likely but manageable. A compliance rejection may be unlikely but catastrophic. This analysis determines urgency, ownership, and the level of response required. It is at this stage that the need for mitigation, escalation, or opportunity investment becomes clear.</p><p>The third step is <strong>documentation.</strong> Identified and analyzed risks are recorded in a risk register that captures not only what the risk is, but why it exists, what it could impact, who owns it, and how it may be handled. In the app project, this becomes the single reference point for technical, operational, and strategic uncertainty. When maintained correctly, it prevents risks from living only in conversations and ensures continuity even when team members change.</p><p>But documentation alone does not reduce risk. This leads to the fourth step: <strong>control and management.</strong> This is where the Project Manager actively integrates risk responses into the project. Mitigation actions are added to the plan, prototypes are scheduled, contracts are adjusted, contingency buffers are created, and escalation paths are defined. For opportunities, resources may be reallocated to increase their likelihood or impact. At this stage, risk management directly shapes how the project is executed.</p><p>Finally, risks must be <strong>reported.</strong> Transparent risk reporting keeps stakeholders aligned with reality. It enables early decisions, builds trust, and prevents surprises. In the learning app project, this may take the form of risk sections in steering meetings, sprint reviews that reassess exposure, and leadership updates when thresholds are approached. Reporting transforms risk from a private concern into a shared management responsibility.</p><blockquote>When risks are identified, analyzed, documented, managed, and reported continuously, uncertainty stops being chaos and becomes context.</blockquote><h3>Understanding risk appetite and risk tolerance</h3><p>Not all organizations view risk the same way.</p><ul><li><strong>Risk appetite</strong> is how much risk an organization is willing to pursue or retain to achieve its objectives.</li><li><strong>Risk tolerance</strong> is how much variation or impact it is willing to accept.</li></ul><p>For example:</p><ul><li>A startup building a learning app may accept high technical and market risk to innovate fast.</li><li>A government or banking client may have extremely low tolerance for security, privacy, and compliance risks.</li></ul><p>As a PM, you must align your decisions with this reality.</p><p>This influences:</p><ul><li>How aggressively you mitigate risks</li><li>Which risks you escalate</li><li>Which risks you may consciously accept</li></ul><p>Risk management without understanding appetite and tolerance often leads to either <strong>over-engineering</strong> or <strong>reckless delivery</strong>.</p><h3>Risk analysis: Probability and impact</h3><p>Once risks are identified, they must be <strong>evaluated and analyzed</strong>.</p><p>Two core parameters guide this:</p><ul><li><strong>Probability</strong> — How likely is it to occur?</li><li><strong>Impact</strong> — How severe would the effect be on time, cost, scope, quality, or reputation?</li></ul><p>In our app project:</p><ul><li>“Content delivery may be late”<br> → High probability, medium impact</li><li>“Payment gateway may reject compliance”<br> → Low probability, very high impact</li><li>“A new feature could go viral and attract investors”<br> → Low probability, high positive impact</li></ul><p>These are often mapped in a <strong>risk matrix</strong> with Low, Medium, and High levels.<br> This helps prioritize attention, resources, and leadership involvement.</p><p>Risk mitigation necessity is determined here — not by fear, but by <strong>structured analysis.</strong></p><h3>Choosing the right response strategies</h3><p>Once a risk is analyzed, the next step is deciding <strong>how to respond.</strong></p><h3>For threats (negative risks):</h3><ul><li><strong>Avoid</strong> — Change the plan to eliminate the risk<br> <em>Example: Remove a risky feature from the first release.</em></li><li><strong>Mitigate</strong> — Reduce probability or impact<br> <em>Example: Build a prototype early to test performance risks.</em></li><li><strong>Transfer</strong> — Shift responsibility to a third party<br> <em>Example: Outsource security testing to a specialized vendor.</em></li><li><strong>Escalate</strong> — Hand over ownership when outside your authority<br> <em>Example: Regulatory risks escalated to legal or leadership.</em></li><li><strong>Accept</strong> — Take no immediate action, but monitor<br> <em>Example: Minor UI delay risk with buffer time.</em></li></ul><h3>For opportunities (positive risks):</h3><ul><li><strong>Exploit</strong> — Ensure it happens<br> <em>Example: Allocate a senior team to fast-track an innovative feature.</em></li><li><strong>Enhance</strong> — Increase probability or impact<br> <em>Example: Invest more marketing support into a promising feature.</em></li><li><strong>Share</strong> — Partner with another party<br> <em>Example: Collaborate with an ed-tech brand.</em></li><li><strong>Escalate</strong> — Move opportunity ownership to decision-makers<br> <em>Example: Investment or expansion opportunities.</em></li><li><strong>Accept</strong> — Acknowledge and monitor<br> <em>Example: Organic user growth possibilities.</em></li></ul><p>Strong PMs don’t just defend projects.<br> They also <strong>position projects to benefit from uncertainty.</strong></p><h3>The real role of the Project Manager in risk management</h3><p>A Project Manager is not expected to predict every problem.</p><p>But a Project Manager is expected to:</p><ul><li>Create visibility around uncertainty</li><li>Ask the right questions early</li><li>Enable informed decisions</li><li>Balance caution with progress</li><li>Protect project objectives while enabling opportunity</li></ul><p>Risk management is where planning meets leadership.</p><p>It transforms a PM from a scheduler into a <strong>strategic partner.</strong></p><h3>Final thought</h3><p>Projects fail rarely because risks existed.</p><p>They fail because risks were:</p><ul><li>Ignored</li><li>Underestimated</li><li>Hidden</li><li>Or addressed too late</li></ul><p>When risk management is practiced properly, uncertainty stops being a threat and starts becoming a <strong>managed space of possibilities.</strong></p><p>And that is one of the strongest professional advantages a Project Manager can develop.</p><blockquote>Risk management is not damage control. It is decision management under uncertainty.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=398a1075b5fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Who will you choose, between a robot and a human?]]></title>
            <link>https://isu-rathnayaka.medium.com/who-will-you-choose-between-a-robot-and-a-human-6695f0a44643?source=rss-dc90ed1bd5------2</link>
            <guid isPermaLink="false">https://medium.com/p/6695f0a44643</guid>
            <dc:creator><![CDATA[Isuruni Rathnayaka]]></dc:creator>
            <pubDate>Sat, 20 Aug 2022 17:49:29 GMT</pubDate>
            <atom:updated>2022-08-20T17:49:29.633Z</atom:updated>
            <content:encoded><![CDATA[<p>If you are asked to choose your best friend from a human and a robot, who will you go for? Seems like a foolish question, isn’t it? Even so don’t forget, with the technological evolution you will have to answer this question in the near future.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*DsDb-Lzs-QOXzA6iDnwW-g.png" /></figure><p>Pre-programmed, Humanoid, Tele-operated, Autonomous, Augmenting, AI-enabled or whatever the type it is, a robot is an excellent human creation that can invade mankind in return. Robots have already been replacing people for years and this will happen increasingly in the next decade. To be exact they are replacing humans in work world, but their capability of ever moving beyond humanity is still questionable.</p><p>Imagine you have a robot friend as you already have human friends. Most of times true friends are considerate about you as same as you. So, if you ask for a help they will do gladly. But if you asked your friend to do that same thing without stopping, what do you think will happen? Wait, think from your perspective, will you do that for your friend? Rather than answering with a no, it should be corrected as cannot. Humans get tired easily and need a rest at least after a week of working, but gladly robots are not. Unless he breakdowns or you turn him off, your robot friend will never get tired or bored and won’t need to take a day off and best of all he won’t ever complain or waste time.</p><p>You get assignments every day and you are overloaded with work. Your human friend will surely help you in your work but he also won’t know answers for all these questions as he has same capabilities and competencies as you. What if your friend is capable of doing all these frustrating assignments in your place so that you can have the highest marks in the class? I’m pretty sure, as a student, you are already dreaming for it to become a reality. Then celebrate, your dream has come true. Artificial intelligence has given robots more ability to process information and to learn. Also, through this they are given more knowledge on several domains even including arithmetic operations and high capacity of memory. So, your artificially intelligent robot friend will be able to finish your all assignments in a glimpse with best results and will be much more helpful than your human friend.</p><p>I agree that your best friend is one of the most trustworthy people in your life but he can make mistakes and can be sometimes unreliable. Besides he can’t be with you every second and there’s always a chance he’ll let you down as he is also a human being with many weaknesses. But always remember, your robot friend will never disappoint you and will make mistakes only because of human errors. He is programmed to work according to set of instructions and therefore he will be consistently good in performance and can be trusted for all your purposes. Also robot friend will also be there for you whenever necessary and stand by your side for 24/7 as your best friend.</p><blockquote>“There are an endless number of things to discover about robotics. A lot of it is just too fantastic for people to believe.”</blockquote><blockquote>-Daniel H. Wilson.</blockquote><p>At this point, you may have already decided to move on with a robot. Don’t hurry, you still have a long way to go before making your decision. You may think that a perfect life of freedom with robot friends, who fulfills all your needs as well as your deepest longings is all you need. But is that really all the life holds?</p><p>Friends or people around you are there for sharing your sadness and to embrace you with laughter while enjoying the life. Now, imagine having an emotionless, just moving and working person beside you all the time. A person with no desire to make you laugh, comfort you in sorrow or understand you. Even thinking this situation seems boring and joyless, isn’t it? But wait, a robot friend is not someone more interesting than how it is described in the sentence you just considered boring. Don’t forget, your robot friend won’t have the emotional intelligence to entertain or comfort you.</p><p>Unlike in the movies, robots are unable to think and make decisions. Your robot friend will do every work for you but that’s all that can be expected. He can’t tell you what to do like your human friend, when you face a difficult situation or want to make a decision. He cannot form memories or use past experiences to make decisions. He is only capable of making choices based on the data that is available with him, however that it is very different from what is meant by a decision. Your human friend will show you the correct path to walk, by giving best advices to make decisions, but robot friend, even won’t know that you have to make a decision. That’s because he can’t put himself in your figurative shoes and sense what you feel.</p><p>Your robot friend will always stand by your side and help you in doing your assignments. Yes, that’s a good thing, but he cannot lead you to do something different or something extra. He will always assist you in the current state but he is not capable of thinking beyond that state or bringing you innovative ideas that can help you for your future success. Nevertheless, your human friend will help you see new opportunities and will work with you for achieving the success through them. Your robot friend will live up to expectations with you, but only human friend will surpass expectations with you.</p><blockquote>“We aren’t robots. What makes us exceptional as humans, is that we have the capacity to feel as many emotions all at once.”</blockquote><blockquote>— Demi Lovato</blockquote><p>Now, you have encountered several facts regarding a robot and a human friend. It’s time to make your decision. So, who will you choose to be your best friend? The choice is yours, but be sure to make it a wise one. One may prefer technology to humanity and another may embrace humanity. Meanwhile, someone will use human intelligence for something more than a choice between a robot and a human.</p><p>In the meantime, don’t forget to think for a moment, the great achievements humans will encounter if a team made up of both robots and human beings working together for a common objective. May be both of them coexisting in parallel, without being limited to just a robot or a human or replacing one from the other, can bring the greatest change to the world. If you think wisely, it is not long before humans and robots can coexist together in a more intertwined manner to conquer higher goals for the betterment of mankind.</p><blockquote>“It’s not a question of either or, robotics or humans,…. The strategy we try to employ is not an either or but the best of both”</blockquote><blockquote>- Sean O’Keeffe</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6695f0a44643" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift Language: Struct Vs Class Vs Protocol]]></title>
            <link>https://isu-rathnayaka.medium.com/swift-language-struct-vs-class-vs-protocol-873f608b794d?source=rss-dc90ed1bd5------2</link>
            <guid isPermaLink="false">https://medium.com/p/873f608b794d</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[struct]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[class]]></category>
            <category><![CDATA[protocol]]></category>
            <dc:creator><![CDATA[Isuruni Rathnayaka]]></dc:creator>
            <pubDate>Mon, 23 May 2022 14:16:15 GMT</pubDate>
            <atom:updated>2022-05-23T14:16:15.143Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2qzVaUCDGGKVPQzHgABocw.png" /></figure><p>Structures and classes are the building blocks of flexible constructs, that helps developers to decide the way of storing data and modeling behavior in their programs. on the other hand, Protocols define blueprint of methods, properties, and other requirements that suit a particular task or piece of functionality., then let it be adopted by a class or a structure provide an actual implementation of those requirements.</p><p><strong>Class</strong></p><p>Class can be termed as a technique used to define and store properties and methods. The “class” keyword is used to create a class in Swift. For example,</p><p>class ClassName {</p><p>// class definition</p><p>}</p><p>Classes are reference types. Reference types are not copied when they’re assigned to a variable or constant or when they’re passed to a function. Rather than a copy, a reference to the same existing instance is used. For example,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a58a8dd1ff95504fdb0c7f532d56f71c/href">https://medium.com/media/a58a8dd1ff95504fdb0c7f532d56f71c/href</a></iframe><p><strong>Struct</strong></p><p>Struct also can be termed as a technique used to define and store properties and methods. The “struct” keyword is used to create a struct in Swift. For example,</p><p>strcut StructName {</p><p>// struct definition</p><p>}</p><p>Structures are value types. It is copied when it’s assigned to a variable or constant, or it’s passed to a function. For example,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6711f94236efffad890710783750f957/href">https://medium.com/media/6711f94236efffad890710783750f957/href</a></iframe><p><strong>Protocol</strong></p><p>Protocol:</p><ul><li>Is a blueprint that a class or struct follows</li><li>Is a communication contract for unrelated objects to rely on</li><li>Defines methods and values</li></ul><p>To put it simply, protocols<strong> </strong>represent interfaces like many other languages do. For example,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/23d47d9bb810fd48723ca7b85ad176f3/href">https://medium.com/media/23d47d9bb810fd48723ca7b85ad176f3/href</a></iframe><p><strong>Similarities in a class, struct and a protocol</strong></p><p>Classes and structs’ shared features that can often be used interchangeably in Swift. However,<strong> protocols when considered alone from class and struct carry orthogonal concepts</strong>. Protocols and classes, structs become fairly similar, but they are never the same. Therefore, only several similarities between classes and structures are mentioned here as follows,</p><p>· Can define properties to store values</p><p>· Can define methods to provide functionality</p><p>· Can define subscripts to provide access to their values using subscript syntax</p><p>· Can be extended to expand their functionality beyond a default implementation</p><p>· Can conform to protocols to provide standard functionality of a certain kind</p><p>However, even classes and structs have differences and uniqueness, that brings the flexibility to developers to use them where they deem best.</p><blockquote>When designing a type, we have to think about whether ownership of a particular instance of this type “has to be shared among different parts of our program, or if multiple instances can be used interchangeably as long as they represent the same value. To share ownership of a particular instance, we have to use a class. Otherwise, we can use a struct.</blockquote><blockquote>Chris Eidhof. “Advanced Swift.”</blockquote><p><strong>Differences between a class, struct and a protocol</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fsheetsu.com%2Ftables%2Fb71782b930&amp;dntp=1&amp;display_name=Sheetsu&amp;url=https%3A%2F%2Fsheetsu.com%2Ftables%2Fb71782b930&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=sheetsu" width="700" height="1702" frameborder="0" scrolling="no"><a href="https://medium.com/media/4cbbc40b4db8e2ce9e8b8b4722d8983a/href">https://medium.com/media/4cbbc40b4db8e2ce9e8b8b4722d8983a/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=873f608b794d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Universal Design for Interactive Systems]]></title>
            <link>https://isu-rathnayaka.medium.com/universal-design-for-interactive-systems-681fc2e9e076?source=rss-dc90ed1bd5------2</link>
            <guid isPermaLink="false">https://medium.com/p/681fc2e9e076</guid>
            <category><![CDATA[interactive-systems]]></category>
            <category><![CDATA[universal-design]]></category>
            <dc:creator><![CDATA[Isuruni Rathnayaka]]></dc:creator>
            <pubDate>Sat, 07 May 2022 13:56:10 GMT</pubDate>
            <atom:updated>2022-05-07T13:56:10.118Z</atom:updated>
            <content:encoded><![CDATA[<h4>“Look at the opportunity of design to empower everyone” — Dan Formosa</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*1_DSA-QghmGvqFk9PwDjJw.png" /></figure><p>Each and every person in the world is different to each other. They have different capabilities, weaknesses, backgrounds, cultures, interests, viewpoints and experiences. So, the way they interact with an interactive system is different. Because of that, it is not fair to come up with a generalized system that can be used by majority of people. However, introducing a design for each variation is also not practical. Therefore, the best solution for this confusion is universal design for interactive systems.</p><p>Universal design for interactive systems is the process of designing interactive systems that are usable by anyone, with any range of abilities, using any technology platform. This can be achieved by designing systems either to have built in redundancy (ex: an interface that has both text and audio methods for inputs) or to be compatible with assistive technologies (ex: an interface that provides text alternatives for graphics, in such a way that they can be read using a screen reader).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*7FWCH2tIeytbBQ7wQYA1nA.png" /></figure><p>As mentioned above the practicality of designing anything so that anyone can use it may be low but we can try to provide an equivalent experience to the users. For this, seven principles of universal design can be applied.</p><h4><strong>Universal design principles</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*_SBiVDLR_rnfDBvayKmMIQ.png" /></figure><p>In the late 1990s a group at North Carolina State University in the USA proposed seven general principles of universal design. These were intended to cover all areas of design and are equally applicable to the design of interactive systems. These principles provide a framework that can be used to develop universal designs. They are;</p><p>1. <strong>Equitable use:</strong> The design is useful and marketable to people with diverse abilities.</p><p>• It provides the same means of use for all users: identical whenever possible; equivalent when not.</p><p>• It avoids segregating or stigmatizing any users.</p><p>• Provisions for privacy, security, and safety are equally available to all users.</p><p>• The design is appealing to all users.</p><p>ex: — A website that is designed so that it is accessible to everyone, including people who are blind.</p><p>2. <strong>Flexibility in use:</strong> The design addresses a wide range of individual preferences and abilities.</p><p>• It provides choice in methods of use.</p><p>• It accommodates right or left handed access and use.</p><p>• It facilitates the user’s accuracy and precision.</p><p>• It provides adaptability to the user’s pace.</p><p>ex: — A website that allows a visitor to choose to read or listen to a description of the contents.</p><p>3. <strong>Simple and Intuitive: </strong>Use of the design is easy to understand, regardless of the user’s experience, knowledge, language skills, or current concentration level.</p><p>• It eliminates unnecessary complexity.</p><p>• It is consistent with user expectations and intuition.</p><p>• It accommodates a wide range of literacy and language skills.</p><p>• It arranges information consistent with its importance.</p><p>• It provides effective prompting and feedback during and after task completion.</p><p>ex: — Provide information in an interface in plain English and avoid using jargon so users can understand the content easily.</p><p>4. <strong>Perceptible Information: </strong>The design communicates necessary information effectively to the user, regardless of ambient conditions or the user’s sensory abilities.</p><p>• It uses different modes (pictorial, verbal, tactile) for redundant presentation of essential information.</p><p>• It provides adequate contrast between essential information and its surroundings.</p><p>• It maximizes “legibility” of essential information.</p><p>• It differentiates elements in ways that can be described (i.e., make it easy to give instructions or directions).</p><p>• It provides compatibility with a variety of techniques or devices used by people with sensory limitations.</p><p>ex: — Enable open/closed captions in videos for users with audiovisual impairments.</p><p>5. <strong>Tolerance for Error:</strong> The design minimizes hazards and the adverse consequences of accidental or unintended actions.</p><p>• It arranges elements to minimize hazards and errors: most used elements, most accessible; hazardous elements eliminated, isolated, or shielded.</p><p>• It provides warnings of hazards and errors.</p><p>• It provides fail safe features.</p><p>• It discourages unconscious action in tasks that require vigilance.</p><p>ex: — In an interface error messages should clearly explain the error and provide clear instructions on fixing the issue.</p><p>6. <strong>Low Physical Effort: </strong>The design can be used efficiently and comfortably and with a minimum of fatigue.</p><p>• It allows user to maintain a neutral body position</p><p>• It uses reasonable operating forces.</p><p>• It minimizes repetitive actions.</p><p>• It minimizes sustained physical effort.</p><p>ex: — Enable keyboard shortcuts for users with limited mobility.</p><p>7. <strong>Size and Space for Approach and Use:</strong> Appropriate size and space is provided for approach, reach, manipulation, and use, regardless of user’s body size, posture, or mobility.</p><p>• It provides a clear line of sight to important elements for any seated or standing user.</p><p>• It makes reaching to all components comfortable for any seated or standing user.</p><p>• It accommodates variations in hand and grip size.</p><p>• It provides adequate space for the use of assistive devices or personal assistance.</p><p>ex: — Allow accessible features such as the pinch-to-zoom function to work on mobile</p><h4><strong>Multi-Modal Interaction</strong></h4><p>The most important fact that we can extract form the seven principles of universal design is providing access to information through more than one mode of interaction. This can be approached through the concept of multi-modal interaction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*0zMmic85xcR25PzZ3kiEjw.png" /></figure><p>Multimodal interaction provides the user with multiple methods for interacting with the system. Simply stating, in multi-modal interaction, for the information input, apart from the traditional keyboard typing, mouse clicking, screen touching, the latest speech and face recognition technology are used.</p><p>For the output, the traditional screen display, the speech and facial expression synthesis and gesture generation are used. Hence, multi-modal systems support the principle of redundancy required for universal design, enabling users to access the system using the mode of interaction that is most appropriate to the abilities they have.</p><p>Most interactive systems often use the visual channel as their primary mode of presentation, through graphics, text, video and animation. In a multi-modal system there are some alternative modes that can be used to provide human–computer communication. Some of them are,</p><p>Ø <strong>Sound in the interface</strong></p><p>Sound is an important contributor to universal design because it enables access for users with visual impairments. There are three types of sound that we could use;</p><p>1. Speech</p><p>Speech related to an interactive system can be mainly of two types;</p><p>o Speech recognition — capability a system has, to process human speech into a written format.</p><p>o Speech synthesis — capability a system has, to translate written information into aural information/ computer-generated simulation of human speech.</p><p>We learn speech naturally as children by listening to and mimicking the speech of those around us. But the speech learning is a complex task. This becomes clear when we try to learn a new language other than mother language, later in life. This complexity makes speech recognition and speech synthesis by computer very difficult.</p><p>2. Non-speech</p><p>Non-speech sounds are audio feedbacks of or to the system, that does not use human speech. For an example, indication of an error with a beep sound can be considered. Some non-speech sound that are used in an interface is;</p><p>o Auditory icons — use natural sounds to represent different types of objects and actions in the interface. For example, as a file is dragged across the screen the noise of paper scraping can be heard.</p><p>3. Earcon</p><p>An Earcon is a structured audio message based on musical sounds which conveys to the user information about the tasks being carried out. For example, while scrolling up and down a page the user gains information on their place in the document.</p><p>Ø <strong>Touch in the interface</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/255/1*lf2ZKErA5bKvm66v02sssA.png" /></figure><p>The use of touch in the interface is known as haptic interaction. Touch in the interface can provide a primary source of information for users with visual impairments and a richer multi-modal experience for sighted users. Some examples of haptic devices are electronic — or soft — braille display and force feedback device.</p><p>Ø <strong>Handwriting recognition</strong></p><p>Handwriting is a very natural form of communication in an interactive system. The major piece of technology used to capture handwriting is the digitizing tablet. However, the variation between the handwriting of individuals is large. Moreover, the handwriting of a single person varies from day to day, and changes over the years. So, handwriting recognition is also a complex activity like speech recognition. Therefore, many of the solutions that are being attempted in speech recognition are also being tried in handwriting recognition systems, such as whole word recognition, the use of context to disambiguate characters, and neural networks, which learn by example.</p><figure><img alt="Handwriting Recognition interface" src="https://cdn-images-1.medium.com/max/287/1*FR-9_WwgYp_AJLJymmgdTA.png" /></figure><p>Ø <strong>Gesture Recognition</strong></p><p>Gesture recognition allows users to interact with the system through body gestures. Being able to control the computer with certain movements of the hand would be advantageous in many situations where there is no possibility of typing, and also this supports communication for people who have hearing loss. But the problem is that, like speech and handwriting, gesture is user dependent. So, the technology for capturing gestures is expensive, using either computer vision or a special data glove.</p><figure><img alt="Automotive gesture recognition system" src="https://cdn-images-1.medium.com/max/272/1*yfgofdb_mIu3TMb_OGPlhw.png" /></figure><h4><strong>Designing for Diversity</strong></h4><p>There are different people in the society as mentioned at the beginning. Therefore, one common interactive design is unfair and one general design can be impractical. But, if people are categorized under some key areas, universal design can be made successful. Ideally, three key areas; disability, age and culture can be considered for this purpose.</p><p>Ø <strong>Designing for users with disabilities</strong></p><p>Considerable portion of the world population has a disability that will affect interaction with computers. So, it has become a legal responsibility to design software and hardware to be accessible by differently abled people so that their job prospects are not disturbed by computing inability. Below are some impairments that should be considered when engaging in interactive system designing;</p><p>· <em>Visual impairment</em></p><p>One of the most common impairment when interaction is concerned, is visual impairment. In text-based interaction, screen readers use synthesized speech or braille output devices provided to receive output and touch-typing to provide input, supporting complete access for computers to people with visual impairments. However, at present there is a rise in graphical interfaces that effects visually impaired people negatively. The best solution for this is, multi-modal interaction. That is use of sounds or touch along with visuals in an interface as mentioned above (in multi-modal interaction).</p><p>· <em>Hearing impairment</em></p><p>Compared to visual impairments most of the interactive systems have addressed hearing impairments. Including gesture recognition along with visuals and sounds in interactive systems can also be considered as a good solution for people with hearing impairments and also it can help to achieve the goal of a universal design.</p><p>· <em>Physical impairment</em></p><p>Physical impairments are of different types. Generally, speech input and output eyegaze system (tracks eye movements to control the cursor), a keyboard driver (attached to user’s head to track movements) and gesture tracking can be used as options in an interactive system to support physically impaired people in many ways.</p><p>· <em>Speech impairment</em></p><p>For users with speech and hearing impairments, multimedia systems provide a number of tools for communication, including synthetic speech and text-based communication and conferencing systems.</p><figure><img alt="Aim of a universal design" src="https://cdn-images-1.medium.com/max/624/1*Ylw9meIOWEOKWvC0CC0nKQ.png" /><figcaption>Aim of a universal design</figcaption></figure><p>Ø <strong>Designing for different age groups</strong></p><p>The way people communicate with an interactive system differs according to the age. Normally, young people learn systems quickly and they are so excited to work with new technology. However, older people and children have specific needs when it comes to interactive technology.</p><p>· <em>Older people</em></p><p>Many older people in the society has at least one impairment they have got with the age. They also have some problems with memory loss. New communication tools, such as email and instant messaging, can provide social interaction in cases where lack of mobility or speech difficulties are available. Mobile technologies can be used to provide memory aids when there is age-related memory loss. Moreover, designs must be clear, simple and forgiving of errors so that they become reliable for older users, paving the path for a universal design.</p><p>· <em>Children</em></p><p>Interfaces that allow multiple modes of input, including touch or handwriting, may be easier for children than keyboard and mouse. Redundant displays, where information is presented through text, graphics and sound will also enhance children’s experience. It is also a good idea to include children in design teams and extract their needs through behaviors.</p><p>Ø <strong>Designing for cultural differences</strong></p><p>Culture difference can be simply interpreted as national cultural differences. However, to promote a universal design, there are some key factors that should be considered. They are;</p><p>- Languages (People who are using different languages should be supported by the design)</p><p>- Cultural symbols (Symbols have different meanings in different cultures. We cannot assume that everyone will interpret symbols in the same way and should ensure that alternative meanings of symbols will not create confusion to the user. The study of the meaning of symbols is known as semiotics)</p><p>- Gestures (Another area where diversity can cause misunderstanding is in the use of gesture. Ex: — In western cultures thumbs up is a sign of approval or agreement but it is considered as an insult in Bangladesh)</p><ul><li>Colors (Colors are often used in interfaces to reflect ‘universal’ conventions. But in reality, one color represents different meanings indifferent cultures. Ex: — red represents life (India), happiness (China) and royalty (France))</li></ul><p>Universal design is about designing systems that are accessible by everyone, everywhere, all the time, regardless of their diversity in disabilities, age and culture. Multi-modal systems provide access to an interactive system through different input and output modes and promotes redundancy. They also allow users to interact in different way, making it more convenient for users with impairments.</p><p>Whenever designers are engaging in an interactive system design, the most important thing they should ask themselves is that whether this design is excluding someone and whether there are any potential confusions or misunderstandings. Only then they can achieve the goal of universal design for interactive systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*JNVWVFxOKgnKNBFO2eTjRg.png" /></figure><blockquote>Diversity is a fact.</blockquote><blockquote>Equity is a choice.</blockquote><blockquote>Inclusion is an action.</blockquote><blockquote>Belonging is an outcome.</blockquote><blockquote>All are part of a universal design approach.</blockquote><blockquote>-Arthur Chan</blockquote><p>Hope the article is useful for you to come up with a universal design for interactive systems. Thank you very much for reading!!!!!!!!!!!!!!</p><p>Isuruni Rathnayaka</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=681fc2e9e076" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Evaluation Techniques for Interactive Systems]]></title>
            <link>https://isu-rathnayaka.medium.com/evaluation-techniques-for-interactive-systems-848434d811d0?source=rss-dc90ed1bd5------2</link>
            <guid isPermaLink="false">https://medium.com/p/848434d811d0</guid>
            <dc:creator><![CDATA[Isuruni Rathnayaka]]></dc:creator>
            <pubDate>Sun, 17 Apr 2022 17:37:07 GMT</pubDate>
            <atom:updated>2022-05-07T13:53:54.699Z</atom:updated>
            <content:encoded><![CDATA[<h4>Techniques to evaluate how far your interactive system supports usability as well as the functionality……..</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p6Ih8jFliTmHZsdbKEHR1g.png" /></figure><p>If good design techniques are used is it necessary to do an evaluation? The answer is yes, it is necessary because evaluations are the key components of a good human computer interaction. Several best designing techniques can be used in the designing process of an interactive system. These can be the best practices to be used in an interactive system to improve the usability. But only an evaluation on the system can depict whether the system actually promote usability and meet the requirements designer expected.</p><h4>Evaluation in an interactive system…</h4><p>Evaluating an interactive system is the process of examining that the system supports both usability and it’s functionality as expected through it’s design as well as implementation. Evaluation also helps to discover modifications that should be done to a system as well as new paths to improve the system.</p><p>Normally, evaluation is not a single phase event in the design life cycle but a process that should done throughout the whole cycle. However, it is important to identify crucial modifications in the early stages of design life cycle as it is much easier to change a design in the early stages than in the later stages.</p><p>If evaluations on an interactive system is necessary, what can we achieved or expect to be achieved from an evaluation?</p><h4>Goals of Evaluation…</h4><p>Ideally, evaluating an interactive system is done with three main goals;</p><ul><li>To assess the extent and accessibility of the system’s functionality</li></ul><p>An interactive system is not a good one just because it is easy to use. Instead the design of the system should support users to perform their expected tasks of the system easily. So, the system’s functionality is completed by the availability and the ease of reachability. Hence, evaluation at this level include measuring the user’s performance with the system, to assess the effectiveness of the system in supporting it’s intended task.</p><ul><li>To assess users’ experience of the interaction</li></ul><p>Users’ experience of the interaction with the system mainly includes how easy the system is to learn, its usability and the user’s satisfaction with it, his enjoyment and emotional response as well as the comfortability a user is having when using the system. Therefore, evaluations with user participation, should be done to discover new modifications that are necessary to achieve best users’ experience.</p><ul><li>To identify any specific problems with the system.</li></ul><p>As a whole, evaluations are done to identify specific problems with the system related to both the functionality and usability of the design. By this designers can identify trouble-spots which can then be rectified before making the system available to users.</p><p>There several evaluation techniques that can be used for the evaluation purpose of an interactive system. These techniques can be categorized mainly under two methods:- expert analysis and user participation.</p><h4>Expert Analysis</h4><p>Evaluation is a continuous process that should be carried out throughout the design life cycle but with evaluations involving users, it can be difficult to get an accurate assessment of the experience of interaction from incomplete designs and prototype during at regular intervals the design process. So, expert analysis can be used as a remedy for this. Expert analysis evaluation techniques can be used at any stage in the development process from a design specification, through storyboards and prototypes, to full implementations, making them flexible evaluation approaches. Main purpose of these is to identify violations in cognitive principles, or any needed design rules. These techniques are also relatively cheap, since they do not require user involvement. Below are some of expert analysis evaluation techniques;</p><p><strong>1.</strong> <strong>Cognitive walkthroughs</strong></p><p>The cognitive walkthrough is an evaluation method in which one or more evaluators walk through sequence of actions refers to the steps that an interface will require a user to perform in order to accomplish a certain task. The main intention of such a walkthrough is to establish how easy a system is to learn through exploration (exploring its functionality hands on, and not after sufficient training or examination of a user’s manual).</p><p>To do a cognitive walkthrough four things are needed;</p><p>1. A specification or prototype of the system.</p><p>2. A description of the task the user is to perform on the system.</p><p>3. A complete, written list of the actions needed to complete the task with the proposed system.</p><p>4. An indication of who the users are and what kind of experience and knowledge the evaluators can assume about them.</p><p>Evaluators in a cognitive walkthrough ask question themselves from the perspective of the user to address this exploratory learning.</p><p>1. Is the effect of the action the same as the user’s goal at that point? (Is this effect the same as what the user is trying to achieve at this point?)</p><p>2. Will users see that the action is available?</p><p>3. Once users have found the correct action, will they know it is the one they need</p><p>4. After the action is taken, will users understand the feedback they get?</p><p>With answers to these questions, evaluators try to find a successful end for each step in the process. If they fail to do so, reasons for the users’ inability to accomplish the task are explored.</p><p>Each evaluator involved in a cognitive walkthrough should record the step in the process where they found an issue and what that issue was. Data is gathered during the walkthrough and a single report on potential issues, is made by the evaluators to redesign the interface to address the issues identified.</p><p><strong>2.</strong> <strong>Heuristic Evaluation</strong></p><p>In a heuristic evaluation, small number of usability evaluators systematically inspect a user interface and make decisions based on predetermined set of usability principles known as heuristics. Heuristics are general rules that describe common properties of usable user interfaces. Although there are numerous heuristics, the most commonly used heuristics in usability evaluation were developed by Jacob Nielsen in 1995, known as the “Heuristics for User Interface Design”. They are published in Nielsen’s book on Usability Engineering as follows;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*MFy2qTKqvJIR1VPNR-IqDg.png" /><figcaption>Jacob Nielsen’s in 10 Heuristics for User Interface Design</figcaption></figure><p><em>Steps in Heuristic Evaluation</em></p><p>To conduct a heuristic evaluation based on above mentioned heuristics, these steps can be followed:</p><p>· Select evaluators</p><p>· Brief evaluators</p><p>· First evaluation phase: In this phase, evaluators will use the product freely to gain the feel of user in the interactions. They will then identify specific elements that should be evaluated.</p><p>· Second evaluation phase: In this phase, evaluators will apply the chosen heuristics to the elements identified during the first phase.</p><p>· Record problems</p><p><strong>3.</strong> <strong>Model based evaluations</strong></p><p>Certain predefined models can be used by expert evaluators to examine an interactive system.</p><p>Several examples for such models are;</p><p>· GOMS (goals, operators, methods and selection) model: — predicts user performance with a particular interface and can be used to filter particular design options.</p><p>· Keystroke-level model (Lower-level modeling technique): — provide predictions of the time users will take to perform low-level physical tasks.</p><p>· Design rationale: — provides a framework in which design options can be evaluated.</p><p>· Dialog models: — evaluates dialog sequences for problems, such as unreachable states, circular dialogs and complexity.</p><p>· State transition networks: — evaluates dialog designs prior to implementation.</p><p><strong>4.</strong> <strong>Using previous studies in evaluation</strong></p><p>Results of studies in previous evaluations can be used as evidence to support interaction of the design. This may not be applicable in every case as designs vary according to the type of users, kind of intended tasks, type of elements used in the design etc. But sometimes a generic issue can be addressed through previous results as it is expensive to repeat experiments. Examples of such scenarios are;</p><p>· Use of generic set of icons</p><p>· Use of similar menu items</p><p>Detailed information regarding expert analysis evaluation techniques are explained in the below article.</p><p><a href="https://isu-rathnayaka.medium.com/usability-evaluation-for-interaction-designs-83105e8a3d2b">Interaction Design: Evaluation</a></p><p>However, these techniques do not address the usability and the functionality of the whole system, but whether or not a system supports accepted usability principles.</p><h4>Usability Evaluations with User Participation</h4><p>Expert Analysis may filter and refine the interactive system but in reality usability of the system by a user can be tested only through the evaluations that involve user participation. Therefore, usability evaluations are important to identify the problems related to the system form user’s perspective. User participation in evaluation tends to occur in the later stages of development when there is at least a high-level prototype of the system as users are not smart enough to deal with low level prototypes.</p><p>There are two common distinct evaluation styles that are used to perform evaluations with user participation. Those are;</p><p><em>1.Laboratory Studies</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*CBqcFGJ8PLmXlesO.jpg" /><figcaption>The Human Computer Interaction Laboratory (HCI)</figcaption></figure><p>Here users are taken out of their normal environment and evaluations are carried out in a controlled environment like a usability laboratory (may simply be a quiet room containing audio/visual recording and analysis facilities, two-way mirrors, instrumented computers etc.). The problem with these laboratories is that they will create an interruption-free and interpersonal communication-free environment which will never be there in the real world. Hence, it is difficult to obtain real results that demonstrate the real world. But in situations like system being implemented in a dangerous or remote location like a space station laboratory observation becomes the only option.</p><p><em>2. Field Studies</em></p><p>Here the evaluator is in the user’s work environment. The real nature of the environment where the evaluation is carried out will make it possible to obtain more reliable and nearly equal results. But the field studies are often disturbed by natural interruptions ambient noise, greater levels of movement and constant interruptions, such as phone calls.</p><p>So, it is better to do evaluation keeping these two styles on balance. Laboratory studies can be applied to scenarios where it seems reliable while engaging in field studies for others.</p><p>There a number of different approaches to evaluation through user participation. Some of them are;</p><p><strong>1. Empirical methods (experimental evaluation)</strong></p><p>One of the best methods of evaluating a design is to use a controlled experiment. A physical experiment is done to obtain results in a statistics based method. This provides empirical evidence to support a particular hypothesis. Here the evaluator;</p><p>· Chooses a hypothesis (A hypothesis is a prediction of the outcome of an experiment.)</p><p>· Clarifies the variables (Experiments manipulate and measure variables under controlled conditions, in order to test the hypothesis. There are two main types of variable: those that are ‘manipulated’ or changed (known as the independent variables) and those that are measured (the dependent variables)).</p><p>· Selects the participants (If participants are not actual users, they should be chosen to be of a similar age and level of education as the intended user group. Participants sample size should be considerably high to engage in statistical methods)</p><p>· Decides on the experimental method that will be used. There are two main methods: between-subjects and within-subjects.</p><p><strong>2. Observational techniques</strong></p><p>By observing the way users interact with the system it is easy to gather information about actual use of a system. Here;</p><p>· Users are asked to complete a set of predetermined tasks.</p><p>· The evaluator watches and records the users’ actions.</p><p>In this section some of the techniques used to evaluate systems by observing user behavior is discussed;</p><p><em>a) Think aloud</em></p><p>Here user is asked to explain what is doing when he is performing a task with the system. By this way, an insight about how the user has understood the system can be obtained by the observer.</p><p><em>b) Cooperative evaluation</em></p><p>It’s a variation of think aloud. Here the user is asked to see himself as a collaborator in the evaluation rather than an experimental participant. User is asked to think aloud at the beginning of the evaluation session and the evaluator can ask the user questions to clarify the behavior of the user. Reversely, user also can ask the evaluator for clarification if a problem arises. Here it is easy for the evaluator to learn the user and his behavior while the user is given the chance to criticize and clarify the system openly.</p><p><em>c) Protocol Analysis</em></p><p>Here the users’ interaction with the system while he is thinking aloud is comprehensively recorded using a media like text, audio, video etc. Then these records are evaluated by an evaluator to identify the users’ perspective of the design and to identify the modifications that should be added.</p><p><em>d) Automated Analysis</em></p><p>Analyzing protocols manually is time consuming and tedious. So, as a solution for this, automatic analysis tools can be used to support the task. These offer a means of editing and annotating video, audio and system logs and synchronizing these for detailed analysis.</p><p><em>e) Post-task walkthroughs</em></p><p>Here the user reflects on the action after the event. This provides <em>analyst time to focus on relevant incidents and avoid excessive interruption of the task. The problem is that, this method lack freshness.</em></p><p><strong>3. Query techniques</strong></p><p>These techniques are about asking the user regarding the interface directly. Query techniques can be useful in eliciting detail of the user’s view of a system. There are two common such techniques as;</p><p><em>a) Interviews</em></p><p>Here, evaluator and the user talk face to face about the his idea on the system based on pre-prepared set of questions. The main thing about an interview is that it’s questions should not be biased misleading the interviewee. This is an informal method which is cost effective but at the same time it is time consuming.</p><p><em>b) Questionnaires</em></p><p>Here, users are given a set of fixed questions to evaluate their understanding and the idea about the system. This is not a very flexible method like interviews but it gives a chance for a large group of people to express their ideas in a short period of time.</p><p><strong>4. Evaluations through monitoring physiological responses</strong></p><p>This is a way of monitoring physiological aspects of computer use. These evaluations allow not only to see more clearly, exactly what users do when they interact with computers, but also to measure how they feel. The two techniques that are receiving the most attention to date are;</p><p><em>a) Eye Tracking</em></p><p>Eye movement measurements are based on fixations, where the eye retains a stable position for a period of time and saccades, where there is rapid ballistic eye movement from one point of interest to another. In this method of evaluation position of the eye is tracked through head or desk mounted equipment. Using that, the following measurements are taken;</p><p>· Number of fixations — The more fixations the less efficient the search strategy</p><p>· Fixations duration — Indicate the level of difficulty with the display</p><p>By analyzing those measurements, the evaluation is conducted. Eye movements are believed to reflect the amount of cognitive processing a display requires and, therefore, how easy or difficult it is to process.</p><p><em>b) Physiological Measurements</em></p><p>Here user’s emotions and physical changes while using the user interface is observed. Through this user’s reaction to an interface can be determined. Following measurements can be considered as primary measurements that are taken in this process;</p><p>· Heart activity, including blood pressure, volume and pulse.</p><p>· The activity of sweat glands: Galvanic Skin Response (GSR)</p><p>· Electrical activity in muscle: electromyogram (EMG)</p><p>· Electrical activity in the brain: electroencephalogram (EEG)</p><p>One of the problems with applying these measurements to interaction events is that it is not clear what the relationship between these events and measurements might be.</p><p>Evaluation is one of the most phase in the designing life cycle. It leads to a perfect and satisfactory interactive product as as it raises the need for change if necessary.</p><p>Hope the article is useful to bring you an understanding about evaluation techniques for interactive systems. Thank you very much for reading!!!!!!!!!!!!!!</p><p>Isuruni Rathnayaka</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=848434d811d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Develop Your Own x86 Operating System(OS) #10]]></title>
            <link>https://isu-rathnayaka.medium.com/develop-your-own-x86-operating-system-os-10-83f6ff3ce18a?source=rss-dc90ed1bd5------2</link>
            <guid isPermaLink="false">https://medium.com/p/83f6ff3ce18a</guid>
            <category><![CDATA[operating-systems]]></category>
            <dc:creator><![CDATA[Isuruni Rathnayaka]]></dc:creator>
            <pubDate>Mon, 27 Sep 2021 13:46:51 GMT</pubDate>
            <atom:updated>2021-09-27T17:37:52.534Z</atom:updated>
            <content:encoded><![CDATA[<h4>User Mode</h4><p>If you can remember we start walking in the road to user mode from the <a href="https://isuruni-rathnayaka0508.medium.com/develop-your-own-x86-operating-system-os-7-49d494f5116b">#7</a> article onwards. Their we advanced our OS so that it can execute a program at the same privilege level as the kernel. Now, we are near the destination of our road, <strong>User mode</strong>.</p><p>If you haven’t read the previous article of the article series Develop Your Own x86 Operating System(OS), it’ high time to read it. You can read it from <a href="https://isuruni-rathnayaka0508.medium.com/develop-your-own-x86-operating-system-os-9-f4733e71d37c">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Rj3JWsfUqPqiQKhE.png" /></figure><p>In the above mentioned article where we starts walking towards user mode, I have explained what is user mode. So, without any further explanations let’s jump on to the implementation of user mode.</p><h3>Segments for User Mode</h3><p>In the article on the segmentation (<a href="https://isuruni-rathnayaka0508.medium.com/develop-your-own-x86-operating-system-os-5-27743b500fab">#5</a>) we set up the GDT and added kernel segments. In a similar way, in order to enable user mode we need to add two more segments to the GDT. They are:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*JAUD5OUZmfgXnKaLlOJT5A.png" /><figcaption>The segment descriptors needed for user mode.</figcaption></figure><p>The difference we can bring with these segments is the Descriptor privilege level (DPL), which allows code to execute in privilege level 3 (PL 3). The segments can still be used to address the entire address space, but just using these segments for user mode code will not protect the kernel. Therefore, For that purpose we need paging.</p><h3>Setting Up For User Mode</h3><p>We can list a few things every user mode process needs:</p><ul><li>Page frames for code, data and stack. At the moment it suffices to allocate one page frame for the stack and enough page frames to fit the program’s code.</li><li>The binary from the GRUB module has to be copied to the page frames used for the programs code.</li><li>A page directory and page tables are needed to map the page frames described above into memory. (At least two page tables are needed, because the code and data should be mapped in at 0x00000000 and increasing while the stack should start just below the kernel, at 0xBFFFFFFB, growing towards lower addresses). The U/S flag has to be set to allow PL3 access.</li></ul><p>It is easy to store this information in a struct representing a process and also this process struct can be dynamically allocated with the kernel’s malloc function.</p><h3>Entering User Mode</h3><p>The only way to execute code with a lower privilege level than the current privilege level (CPL) is to implement an <em>iret (</em>interrupt return<em>)</em> or <em>lret (</em>long return<em>) </em>instruction.</p><p>To enter the user mode we should set up the stack as if the processor had raised an inter-privilege level interrupt. The stack should look like the following:</p><pre>[esp + 16]  ss      ; the stack segment selector we want for user mode<br>[esp + 12]  esp     ; the user mode stack pointer<br>[esp +  8]  eflags  ; the control flags we want to use in user mode<br>[esp +  4]  cs      ; the code segment selector<br>[esp +  0]  eip     ; the instruction pointer of user mode code to execute</pre><p>The instruction <em>iret</em> will then read these values from the stack and fill in the corresponding registers.</p><p>Before we execute <em>iret</em> we need to change to the page directory we setup for the user mode process.</p><p>In order to continue executing kernel code after we’ve switched PDT, the kernel needs to be mapped in. By maintaining a separate PDT for the kernel, which maps all data at <em>0xC0000000 </em>and above, and merge it with the user PDT which only maps below <em>0xC0000000</em> we can<em> </em>accomplish this. Note that the physical address of the PDT should be used when setting the <em>cr3 </em>register.</p><p>The register <em>eflags </em>contains a set of different flags and for us the most important one is the interrupt enable (IF) flag. If interrupts are disabled when entering user mode, then interrupts can’t be enabled once user mode is entered. Setting the IF flag in the <em>eflags </em>entry on the stack will enable interrupts in user mode, since the assembly code instruction <em>iret </em>will set the register <em>eflags </em>to the corresponding value on the stack.</p><p>For now, we should have interrupts disabled, as it is somewhat difficult to get inter-privilege level interrupts to work properly but we will implement this in an upcoming article.</p><p>The value <em>eip </em>on the stack should point to the entry point for the user code - <em>0x00000000 and t</em>he value <em>esp </em>on the stack should be where the stack starts - <em>0xBFFFFFFB </em>(<em>0x00000000-4</em>) in our implementation.</p><p>The values <em>cs </em>and <em>ss </em>on the stack should be the segment selectors for the user code and user data segments, respectively. The lowest two bits of a segment selector is the RPL (Requested Privilege Level). When using <em>iret </em>to enter PL3, the RPL of<em> cs </em>and <em>ss</em> should be <em>0x3</em>. The following code shows an example:</p><pre>USER_MODE_CODE_SEGMENT_SELECTOR equ 0x18<br>USER_MODE_DATA_SEGMENT_SELECTOR equ 0x20<br><strong>mov</strong> <strong>cs</strong>, USER_MODE_CODE_SEGMENT_SELECTOR | 0x3<br><strong>mov</strong> <strong>ss</strong>, USER_MODE_DATA_SEGMENT_SELECTOR | 0x3</pre><p>The register <em>ds</em>, and the other data segment registers, should be set to the same segment selector as <em>ss</em>. They can be set with the <em>mov</em> assembly code instruction which is the ordinary way we have used.</p><p>We have now set all the features needed to execute iret. If everything of the above process has been set up right, we should now have a kernel that can enter user mode.</p><h3>Using C for User Mode Programs</h3><p>If we are going to use C as the programming language for user mode programs, it is a must to think about the structure of the file that will be the result of the compilation.</p><p>The reason we can use ELF as the file format for for the kernel executable is because GRUB knows how to parse and interpret the ELF file format. If we implemented an ELF parser, we could compile the user mode programs into ELF binaries as well. This may not be easy as it seems.</p><p>One action we can take to make it easier to develop user mode programs is to allow the programs to be written in C, but compile them to flat binaries instead of ELF binaries.</p><p>In C the layout of the generated code is more unpredictable and the entry point, <em>main</em>, might not be at offset 0 in the binary. One way to circumvent this is to add a few assembly code lines placed at offset 0 which calls <em>main</em>:</p><pre><strong>extern</strong> main<br><br>    <strong>section</strong> .text<br>        <em>; push argv</em><br>        <em>; push argc</em><br>        <strong>call</strong> main<br>        <em>; main has returned, eax is return value</em><br>        <strong>jmp</strong>  $    <em>; loop forever</em></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AAgIQOdXpd3vhMwvxtn_aw.png" /></figure><p>The following code show an example of a linker script that places these instructions first in executable (start.s gets compiled to start.o):</p><p>With this script we can write programs in C or assembler, and it is easy to load and map for the kernel (.rodata will be mapped in as writeable, though).</p><p>When we compile user programs we want the following GCC flags:</p><pre>-m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs</pre><p>For linking, the followings flags should be used:</p><pre>-T link.ld -melf_i386  # emulate 32 bits ELF, the binary output is specified in the linker script</pre><p>The option -T instructs the linker to use the linker script link.ld.</p><p>Hope you have gain some knowledge on user mode. Let’s meet with the next article of Develop Your Own x86 Operating System(OS) series. Thank you so much for reading!!!!!!!!!!</p><p>Isuruni Rathnayaka</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83f6ff3ce18a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Develop Your Own x86 Operating System(OS) #9]]></title>
            <link>https://isu-rathnayaka.medium.com/develop-your-own-x86-operating-system-os-9-f4733e71d37c?source=rss-dc90ed1bd5------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4733e71d37c</guid>
            <category><![CDATA[operating-systems]]></category>
            <dc:creator><![CDATA[Isuruni Rathnayaka]]></dc:creator>
            <pubDate>Fri, 10 Sep 2021 13:42:52 GMT</pubDate>
            <atom:updated>2021-09-27T07:46:12.960Z</atom:updated>
            <content:encoded><![CDATA[<p>Page Frame Allocation</p><p>In the previous article we discussed about the virtual memory and paging in details. Through this article let’s get an idea about page frame allocation, the technique of informing the operating system, the parts of memory that are free to use when dealing with virtual memory.</p><p>If you haven’t gone through the previous article on paging, please be sure read it from <a href="https://isuruni-rathnayaka0508.medium.com/develop-your-own-x86-operating-system-os-8-78a25b945dde">here</a>, in order to understand this article as this is an extension of that process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*5KwjI7SPTFZQaPNR.png" /></figure><p>Paging is an important part of virtual memory implementations in modern operating systems. It is the most common technique used in x86 to enable virtual memory. We discussed a lot of details about paging in the previous article. When writing an operating system for any architecture, one of the most important functions you’ll have to write is the page frame allocator. So, let’s discuss about page frame allocation now.</p><p>Page Frame Allocation is the process of allocating the part of memory to be used by the Operating system. More precisely, “When using virtual memory, how does the OS know which parts of memory are free to use?”, that is the role of the page frame allocator.</p><p>Therefore, let’s look in to the step by step of managing the available memory.</p><p>Add identity mapping for the first 4 MB of the virtual address space.<br>Add an entry for 0xC0100000 that maps to 0x00100000</p><p>We have to be careful when using memory-mapped I/O that uses specific memory locations. Ex: — The frame buffer is located at 0x000B800, but since there is no entry in the page table for the address 0x000B800 any longer, the address 0x000B800 must be used, since the virtual address 0xC000000 maps to the physical address 0x0000000.<br>Any explicit references to addresses within the multiboot structure needs to be changed to reflect the new virtual addresses as well.</p><h3>Managing Available Memory</h3><p>In order to manage the available memory first of all we have to know how much memory is available on the computer the OS is running on.</p><h4>How Much Memory is There?</h4><p>The simplest way that can be followed to do this is to read it from the multiboot structure passed to us by GRUB. I hope you can remember what a multiboot structure is as we have discussed it in a previous article (#7).</p><p>GRUB is on duty to collect the information we need to know about the memory (what part of memory is reserved, I/O mapped, read-only etc.). Specially remember that the GRUB doesn’t mark the part of memory used by the kernel as reserved so, it’s our responsibility to make sure that we don’t mark this memory as free.</p><p>There is one simple way to know the amount of memory the kernel uses. It is to export labels at the beginning and the end of the kernel binary from the linker script:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7985fd7bb396832598948af202ef6783/href">https://medium.com/media/7985fd7bb396832598948af202ef6783/href</a></iframe><p>These labels can be read using assembly code and pushed on the stack to make them available to C code. Update loader.s file as below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/13a375ba58dea1140cd4c0661d65006c/href">https://medium.com/media/13a375ba58dea1140cd4c0661d65006c/href</a></iframe><p>This way we get the labels as arguments to kmain.</p><p>Assembly code may be very bothersome to you, so you may prefer C over assembly. Hence, if you want to use C there you can easily to this by declaring the labels as functions and take the addresses of these functions. An example is given below for demonstration:</p><p>If you use GRUB modules you need to make sure the memory they use is marked as reserved as well.</p><p>The available memory to be used, does not need to be contiguous.</p><h4>How can we manage available memory?</h4><p>It’s convenient to divide the memory sections into complete page frames, since we can’t map part of pages into memory. But is there a way for us to fin about which page frames are in use and which are not?</p><p>As mentioned earlier in the article, it is the responsibility of the page frame allocator to keep track of page frames which are free and which aren’t.</p><p>There are many methods of page frame allocation, each with varying levels of complexity and efficiency. Some of those methods are <strong>Bitmaps, linked lists, trees, the Buddy System (used by Linux), sized portion scheme, hybrid scheme etc.</strong></p><p><strong>Bitmaps</strong> are easy to implement. Here, one bit is used for each page frame and one or more page frames are dedicated to store the bitmap. In <strong>Linked lists</strong> method, the address of each available physical frame is stored in a stack-like dynamic structure. <strong>Buddy Allocation System</strong> is the physical memory allocator of Linux kernel. A buddy for N pages is about twice the size of a bitmap for the same area, but it allows a faster location of collections of pages. In <strong>Hybrid scheme a</strong>llocators may be chained so that for an example a stack only covers the last operations and that the ‘bottom’ of the stack is committed to a bitmap. In this way, if the stack lacks pages, it can scan the bitmap to find some.</p><h3>Method of Accessing a Page Frame</h3><p>The page frame allocator returns the physical start address of the page frame. But if this page frame is not mapped in, no page table will point to this page frame. So, how can we read and write data to the frame? It’s time to find out.</p><p>As the first step we need to map the page frame into virtual memory, by updating the PD or PT used by the kernel. But if all available page tables are full, then we can’t map the page frame into memory as we face with the necessity of a new page table. This will take up an entire page frame. Not only that in order to write to this page frame we’d need to map its page frame. May be we would find a solution if we succeed in breaking this dependency of pge tables and page frames on each other.</p><p>One solution is to reserve a part of the first page table used by the kernel (or some other higher-half page table) for temporarily mapping page frames to make them accessible. If the kernel is mapped at 0xC0000000 (page directory entry with index 768), and 4 KB page frames are used, then the kernel has at least one page table. If we assume - or limit us to - a kernel of size at most 4 MB minus 4 KB we can dedicate the last entry (entry 1023) of this page table for temporary mappings. The virtual address of pages mapped in using the last entry of the kernel’s PT will be:</p><p>After we’ve temporarily mapped the page frame we want to use as a page table, and set it up to map in our first page frame, we can add it to the paging directory, and remove the temporary mapping.</p><h3>A Kernel Heap</h3><p>So far we’ve only been able to work with fixed-size data, or directly with raw memory. Now that we have a page frame allocator we can implement malloc and free to use in the kernel.</p><p>The only modification we need to do is to replace calls to sbrk/brk with calls to the page frame allocator when more memory is needed. We must also make sure to map the page frames returned by the page frame allocator to virtual addresses. A correct implementation should also return page frames to the page frame allocator on call to free, whenever sufficiently large blocks of memory are freed.</p><p>References:</p><p><a href="https://littleosbook.github.io/">LittleOSBook</a></p><p><a href="https://wiki.osdev.org/Page_Frame_Allocation">Page Frame Allocation</a></p><p><a href="https://wiki.osdev.org/Writing_A_Page_Frame_Allocator">Writing A Page Frame Allocator</a></p><p><a href="https://anastas.io/osdev/memory/2016/08/08/page-frame-allocator.html">OSDEV: Implementing a basic x86 page frame allocator in C</a></p><p>Hope you understand what page frame allocation is. Let’s meet with the next article of Develop Your Own x86 Operating System(OS) series. Thank you so much for reading!!!!!!!!!!</p><p>Isuruni Rathnayaka</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4733e71d37c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is that really all, the word “leadership” holds?]]></title>
            <link>https://isu-rathnayaka.medium.com/is-that-really-all-the-word-leadership-holds-bd802557b190?source=rss-dc90ed1bd5------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd802557b190</guid>
            <dc:creator><![CDATA[Isuruni Rathnayaka]]></dc:creator>
            <pubDate>Tue, 07 Sep 2021 20:38:32 GMT</pubDate>
            <atom:updated>2021-09-07T20:45:43.382Z</atom:updated>
            <content:encoded><![CDATA[<h4>“Leadership is an action, not a position.” - Donald McGannon</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*wJqtVBuYxgbt5KHPH47ODg.png" /></figure><p>People have been accustomed in working as a team under a leader ever since the life began. Hence, the word “leadership” has been shaped with different definitions for a long time. Most of these describes leadership as just leading a group of people but is that really all, the word “leadership” holds?</p><p>Leadership may be all about leading a team, but leading is not just about advising team members what to do and how to do. Rather than guiding the team, a leader should work shoulder to shoulder with all members in achieving team goals. Leader has to motivate himself and urge to give best of his abilities to the team work. Only then, subordinates get motivated to provide their best to the team. Likewise, leader should utilize his intelligence and experience to guide the employees in the correct path when necessary. A great leader leads a team by exemplary actions not only with words.</p><p>A leader should always have a comprehensive understanding of his teammates, including their level of competency as well as individual strengths and weaknesses. Awareness on their level of knowledge about a particular domain, is the most important factor for the accomplishment of a team goal. One member may be very talented in a certain field of study while another is not. So, it’s the responsibility of leader to deploy tasks according to the ability of individuals while creating an environment with opportunities for them to grow in different aspects. People are different so their personal goals also. Therefore, a leader should help members realize their goals by bridging individual goals and team’s objectives.</p><p>A leader must be responsible towards his actions as well as subordinates’. If the leader is accountable, the trust towards the leader within the team improve. Similarly, the leadership must be bounded with friendliness, humanity and empathy. A leader must be friendly with fellow members by sharing the feelings, opinions and desires. In a team, a leader can be superior but he always deals with another human being, so humanity is a must to be practiced. Leader should always try to look at problems with the employees’ point of view and to explore solutions favorable for them.</p><p>Leadership is not an easy task. If one misunderstands leadership as the exercise of power, he or she is not eligible to be a leader. One should be mindful of power he holds and the way of employing the power, as a leader. A leader is someone who gives life to the dreams of people who follow and believe in him. Leader has to keep exemplary footprints so that his fellow members can follow. Remember to lead with efforts and an understanding, as a leader to be able to hold the best leadership.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd802557b190" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Develop Your Own x86 Operating System(OS) #8]]></title>
            <link>https://isu-rathnayaka.medium.com/develop-your-own-x86-operating-system-os-8-78a25b945dde?source=rss-dc90ed1bd5------2</link>
            <guid isPermaLink="false">https://medium.com/p/78a25b945dde</guid>
            <category><![CDATA[operating-systems]]></category>
            <dc:creator><![CDATA[Isuruni Rathnayaka]]></dc:creator>
            <pubDate>Mon, 06 Sep 2021 15:47:58 GMT</pubDate>
            <atom:updated>2021-09-16T13:25:37.968Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction to Virtual Memory and Paging</h4><p>Previous article onwards we are walking in the path to execute a program in user mode. If you haven’t gone through the previous article on road to user mode, please read it from <a href="https://isuruni-rathnayaka0508.medium.com/develop-your-own-x86-operating-system-os-7-49d494f5116b">here</a> to understand the process going on, in this article.</p><p>Through this article let’s have a quick overview on virtual memory and dive deep to learn about paging, a method of organizing the memory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Y5xLz8M1-bsHs6EJ.png" /></figure><p>Physical memory is the computer’s random access memory (RAM), typically contained in DIMM cards attached to the computer’s motherboard. Virtual memory is a portion of an HDD or SSD that is reserved to emulate RAM. The memory management unit(MMU) serves up virtual memory from disk to the CPU to reduce the workload on physical memory.</p><h3>Introduction to Virtual Memory</h3><p>In computing, <strong>virtual memory </strong>is a memory management technique which provides an abstraction of physical memory available on a given machine, creating the illusion to users of a very large main memory. The purpose of virtual memory is generally to simplify application development, to let processes address more memory than what is actually physically present in the machine and to stop applications messing with the kernel or other applications’ memory due to security.</p><p>In the x86 architecture, virtual memory can be accomplished in two ways: <strong><em>segmentation</em> and <em>paging</em>. </strong><em>Paging</em> is a computer memory management function that presents storage locations to the computer’s CPU as additional memory, called virtual memory. <em>Segmentation</em> is a virtual process that creates variable-sized address spaces in computer storage for related data, called segments.</p><p>Paging is by far the most common and versatile technique, but some use of segmentation is still needed to allow for a program to execute under different privilege levels. So, let’s run through these two ways separately.</p><h3>Virtual Memory Through Segmentation</h3><p>We have discussed about memory management through segmentation in details through a previous article(<a href="https://isuruni-rathnayaka0508.medium.com/develop-your-own-x86-operating-system-os-5-27743b500fab">#5</a>). Segmentation can be used entirely for virtual memory, ignoring paging completely. If we continue this way, no process can see the memory of another process and each user mode process would get its own segment, with base address and limit properly set up. It seems fine and better to take into action, but the problem prevailing in this method is that, the physical memory for a process needs to be contiguous. Moreover, we must know in advance how much memory the program will require (which is not pragmatic), or we can move the memory segments to places where they can grow when the limit is reached (which is expensive and causes fragmentation).</p><p>Both the methods mentioned above that arises with using segmentation for virtual memory, are troublesome. So, it is better if we can follow another way for virtual memory that avoids these problems. Amazingly, Paging solves both of these problems.</p><p>Prior to discussion on virtual memory through paging, let’s see what is paging.</p><h3>Paging</h3><p>Paging is a memory management scheme that eliminates the need for contiguous allocation of physical memory. It is the process of translating linear addresses converted in segmentation, onto the physical address space and determining access rights and the way memory should be cached.</p><p>In paging, secondary memory and main memory are divided into equal fixed size partitions. The partitions of secondary memory (logical memory) are called as <strong>pages </strong>while<strong> </strong>the partitions of main memory (physical memory) are called as <strong>frames</strong>. The size of a frame should be kept the same as that of a page to have maximum utilization of the main memory and to avoid external fragmentation.</p><h4>Paging in x86</h4><p>Paging is achieved through the use of the Memory Management Unit (MMU). On the x86, the MMU maps memory through a series of tables, two to be exact. They are the paging directory (PD), and the paging table (PT).</p><p>Page directory (PD) can contain references to 1024 page tables (PT), each of which can point to 1024 sections of physical memory called page frames (PF).</p><p>A page frame is the smallest fixed-length contiguous block of physical memory into which memory pages are mapped by the operating system. Each page frame is 4096 byte large.</p><p>The topmost paging structure is the page directory. It is essentially an array of page directory entries that take the following form.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/0*1UwG3y0sju55-lWm.png" /></figure><p>Page Table is a data structure used by the virtual memory system to store the mapping between logical addresses and physical addresses. It converts the page number of the logical address to the frame number of the physical address. In each page table there are also 1024 entries. These are called page table entries, and are similar to page directory entries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/0*WQ2VwtaTHejXB2ym.png" /></figure><p>The bits <em>U/S </em>determines what privilege levels can access this page (PL0 or PL3), and <em>R/W </em>bits<em> </em>makes the memory in the page read-write(set) or read-only(unset). 4 bytes times 1024 equals 4096 bytes, so a page directory and page table both fit in a page frame themselves.</p><p>Note:</p><p>An instruction that can be used when updating a PD or PT is <em>invlpg</em>. It invalidates the <em>Translation Lookaside Buffer</em> (TLB) entry for a virtual address. The TLB is a cache for translated addresses, mapping physical addresses corresponding to virtual addresses. This instruction is only required if we have to change a PDE or PTE that was previously mapped to something else. If the PDE or PTE had previously been marked as absent, executing<em> invlpg</em> instruction is unnecessary. Changing the value of <em>cr3</em> will cause all entries in the TLB to be invalidated.</p><p>Invalidating a TLB entry can be presented as below:</p><pre><em>; invalidate any TLB references to virtual address 0<br></em><strong>invlpg</strong> [0]</pre><p>In a virtual (linear) address, the highest 10 bits specifies the offset of a page directory entry (PDE) in the current PD, the next 10 bits the offset of a page table entry (PTE) within the page table pointed to by that PDE. The lowest 12 bits in the address is the offset within the page frame to be addressed.</p><p>All page directories, page tables and page frames need to be aligned on 4096 byte addresses. This makes it possible to address a PD, PT or PF with just the highest 20 bits of a 32 bit address, since the lowest 12 need to be zero.</p><p>The translation of linear addresses to physical addresses (the process of paging) is shown in the figure below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*bHf3ulpcvM5Drq41LYxlLw.png" /><figcaption><em>“Translating virtual addresses (linear addresses) to physical addresses”</em></figcaption></figure><p>The linear address gets translated to a physical address by the MMU and the page table. If the virtual address isn’t mapped to a physical address, the CPU will raise a page fault interrupt.</p><p>Pages are normally 4096 bytes, but it is also possible to use 4 MB pages. Then a PDE points directly to a 4 MB page frame, which needs to be aligned on a 4 MB address boundary. In this way also the address translation is almost the same as in the figure, except the page table step. It is possible to mix 4 MB and 4 KB pages.</p><p><strong>Identity Paging</strong></p><p>This is the simplest kind of paging. Identity Paging, Identity Mapped Paging and 1:1 Paging are terms often used for mapping virtual addresses to physical addresses that have the same value. This means that if paging is enabled with identity paging, <em>0xb8000 </em>is<em> 0xb8000</em>. Identity paging can be done at compile time by creating a page directory where each entry points to its corresponding 4 MB frame. In NASM this can be done with macros and commands (<em>% rep, times and dd</em>). And also this can be done at run-time by using ordinary assembly code instructions.</p><h4><strong>Enabling Paging</strong></h4><p>The 20 bits pointing to the current PDT is stored in the <em>cr3</em> register and the lower 12 bits of <em>cr3 </em>are used for configuration.</p><p>Enabling paging is done by first writing the address of a page directory to <em>cr3</em> and then setting bit 31, the PG “paging-enable” bit of<em> cr0</em> to 1. To use 4 MB pages, set the PSE bit (Page Size Extensions, bit 4) of <em>cr4.</em></p><p>C code cannot directly access the registers, so assembly code is used to access CR3.The following assembly code shows how this can be done:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d47ccc1eca8dd5f470a18baf0618b21/href">https://medium.com/media/9d47ccc1eca8dd5f470a18baf0618b21/href</a></iframe><p>Create page_enable.s file in your working directory and save the above code in it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MvMF57nUMrd5sMltZVNXjA.png" /><figcaption>“Now you will see your page_enable.s file”</figcaption></figure><p>Don’t forget to put page_enable.o in the OBJECT variable of Makefile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vOEUZkKY3bg6mI1VpegxaA.png" /></figure><p>It is better to run your OS using identity paging before trying to implement a more advanced paging setup, as it can be hard to debug a malfunctioning page table set up through assembly code.</p><p>Note that all addresses within the page directory, page tables and in <em>cr3</em> should be physical addresses to the structures not virtual.</p><h3>Paging and the Kernel</h3><p>Now let’s see how this paging effects the heart of OS, the Kernel.</p><p>Generally, in the linking process, the linker assumes that the code will be loaded into the memory position <em>0x00000000</em>. Therefore, when resolving absolute references, <em>0x00000000 </em>will be the base address for calculating the exact position. But if the kernel is mapped on the beginning of the virtual address space (<em>0x00000000</em>, “Size of kernel”), the user mode process cannot be loaded at virtual address <em>0x00000000. </em>Therefore, the assumption from the linker that the user mode process is loaded into memory at position <em>0x00000000 </em>becomes wrong. Although this can be corrected by using a linker script which tells the linker to assume a different starting address, it will be unmanageable for the users of the operating system.</p><p>That being the case, the kernel should be placed at a very high virtual memory address, for example 0xC0000000(3 GB). Now the only way that a user mode process can conflict with the kernel is it’s being 3 GB large, but it is not a common scenario.</p><p>When the kernel uses virtual addresses at 3 GB and above it is called a <em>higher-half kernel</em>. Selecting the correct address to place the kernel depends on how much virtual memory should be available for the kernel and how much virtual memory should be available for the process. If the user mode process is larger than 3 GB, some pages will be needed to swap out by the kernel. But, we are not discussing about swapping pages here.</p><h4>Placing the Kernel at 0xC0000000</h4><p>As taken in the example above, now let’s see how we can place the Kernel at <em>0xC0000000</em>.</p><p>At first, place the kernel at <em>oxC0100000 </em>than <em>0xC0000000.</em> This way it is possible to map (<em>0x00000000,</em> <em>0x00100000</em>) to (<em>0xC0000000</em>, <em>0xC0100000</em>). This way, the entire range (<em>0x00000000</em>, “Size of kernel”) of memory is mapped to the range (<em>0xC0000000</em>, <em>0xC0000000 + &quot;</em>“Size of kernel”).</p><p>When the linker resolves all absolute references in the kernel, it will make the assumption that the kernel is loaded at physical memory location <em>0x00100000 not at 0x00000000</em> as we used relocation in the linker script. We want the jumps to be resolved using <em>0xC0100000 </em>as base address, otherwise a kernel jump will jump straight into the user mode process code as user mode process is loaded at virtual memory <em>0x00000000</em>.</p><p>We want kernel to be loaded at the physical address <em>0x00100000. </em>So, this cannot be done by simply telling the linker to assume that the kernel loads at <em>0xC0100000</em>. There is BIOS and GRUB code loaded below 1 MB and so it is good to load the kernel at 1 MB. Furthermore, the computer might not have 3 GB of physical memory so, loading the the kernel at <em>0xC0100000 </em>is not a good idea either. This problem can be given a solution using both relocation (.=0xC0100000) and the <em>AT</em> instruction in the linker script. <strong>Relocation</strong> specifies that non-relative memory-references should use the relocation address as base in address calculations. <strong>AT instruction </strong>specifies the place where the kernel should be loaded into memory. Relocation is done at link time by GNU ld, the load address specified by AT is handled by GRUB when loading the kernel, and is part of the ELF format.</p><h4>Higher-half Linker Script</h4><p>For this we have to modify the link.ld to implement this. The following code can be used:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ebdb91244c26c476708f69155018f7e8/href">https://medium.com/media/ebdb91244c26c476708f69155018f7e8/href</a></iframe><p>When GRUB jumps to the kernel code, there will be no paging table. Therefore, all references to <em>0xC0100000 + x </em>won’t be mapped to the correct physical address, and will therefore cause a general protection exception or the computer will just crash.</p><p>Therefore, using the C language we have to set up a page table and page directory.</p><h3>Virtual Memory Through Paging</h3><p>Paging is an important part of virtual memory implementations in modern operating systems. It is the most common technique used in x86 to enable virtual memory. Virtual memory through paging means that each process will have the feeling that the available memory range is 0x00000000–0xFFFFFFFF although the actual size of the memory might be much less than that. This also means that when a process addresses a byte of memory it will use a virtual (linear) address instead of physical one.</p><p>Paging enables two things that are good for virtual memory.</p><p><strong>&lt;&gt;</strong> It allows for fine access control to memory (Pages can be marked as read-only, read-write, only for PL0 etc.).</p><p><strong>&lt;&gt;</strong>It creates the illusion of contiguous memory. User mode processes, and the kernel, can access memory as if it were contiguous, and the contiguous memory can be extended without moving data around in memory.</p><p>Paging is optional, and some operating systems do not make use of it. But if we want to have processes running at different privilege levels, paging is the best way to do it.</p><p>Now, you have learnt many of theories related to paging. It’s time use them practically in order to initiate paging using the C language. Let’s create files needed for this one by one.</p><p>First let’s create common.h, which is a simple header file. Save the file with the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5473d24b6fa88c8ab9bfbe19872a8676/href">https://medium.com/media/5473d24b6fa88c8ab9bfbe19872a8676/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AGH9W4-01VVQnFdFVeGsQg.png" /><figcaption>“Now you will see common.h file”</figcaption></figure><p>Now create common.c file and save this code in it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e973639e2ed37e4266550d05ebe9f34d/href">https://medium.com/media/e973639e2ed37e4266550d05ebe9f34d/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TGr574K9p5pNQRl4_x597Q.png" /><figcaption>“Now you will see common.c file”</figcaption></figure><p>As the next step create kheap.h header file for the heap of kernel with the below code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fa3627b7f97c0166e2530ce6a768e424/href">https://medium.com/media/fa3627b7f97c0166e2530ce6a768e424/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qk6NvIZ2p2BDcZI5xIOJaw.png" /><figcaption>“Now you will see kheap.h file”</figcaption></figure><p>and kheap.c file with the code given below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf639c9dfc4821fffbb0f6cad6f93c15/href">https://medium.com/media/cf639c9dfc4821fffbb0f6cad6f93c15/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OpItD5aKzMKS-7gjC3jqhQ.png" /><figcaption>“Now you will see kheap.c file”</figcaption></figure><p>It’s time for enabling paging using C language. For this we have to first create paging.h file that contains function declarations and Page Directory Entity structure as well as Page Table Entity structure. Following code can be used for paging.h:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0e73c8339f0cb5dad8d8bae64bb0ea06/href">https://medium.com/media/0e73c8339f0cb5dad8d8bae64bb0ea06/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XUAzfqMYkHVRuH0FWl4NVw.png" /><figcaption>“Now you will see paging.h file”</figcaption></figure><p>Using the paging.c file we can specify function definitions. The following code can be used for it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9eb425d970bde73af1239d7a1d1292a2/href">https://medium.com/media/9eb425d970bde73af1239d7a1d1292a2/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7zvZU1MvaIDnhcI5qD4zcQ.png" /><figcaption>“Now you will see paging.c file”</figcaption></figure><p>Again it’s time to update your Makefile with .o files:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HPuPQ4nJMnWPk63oYN8zMg.png" /><figcaption>“Update OBJECT variable like this”</figcaption></figure><p>Now the kmain.c file should be updated including only these two highlighted lines:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*1rNxYtTPnPD18KJmbwladA.png" /><figcaption>“Now your kmain.c file will look like this”</figcaption></figure><p>We created files for interrupt handling in a previous article (<a href="https://medium.com/codex/develop-your-own-x86-operating-system-os-6-68605f50d522">#6</a>). In this step we have to update some of those files to obtain an interrupt handler for page faults.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*bhP6tuO56ripEqUDIUcLCw.png" /><figcaption>“Update interrupt_handler.s file with the highlighted line”</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rntM7R6dsQEQcdUp2LCDnQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LqkmonS2RhcMmo30-N0xfg.png" /><figcaption>“Finally update interrupt_handler function in interrupts.c as shown in the diagram”</figcaption></figure><p>Now, boot your OS using the “<em>make run</em>” command, if the process end successfully you have integrated paging.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vegVk7ilwxXINK9mI2J0YQ.png" /></figure><p>Now you have learnt about virtual memory and paging in x86. In the next article you will be able to study about page frame allocation.</p><p>References</p><p><a href="https://wiki.osdev.org/Paging">Paging</a></p><p><a href="https://wiki.osdev.org/Higher_Half_bare_bones">Higher Half x86 Bare Bones</a></p><p>Hope you understand what is paging and virtual memory. Let’s meet with the next article of Develop Your Own x86 Operating System(OS) series. Thank you so much for reading!!!!!!!!!!</p><p>Isuruni Rathnayaka</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78a25b945dde" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Develop Your Own x86 Operating System(OS) #7]]></title>
            <link>https://isu-rathnayaka.medium.com/develop-your-own-x86-operating-system-os-7-49d494f5116b?source=rss-dc90ed1bd5------2</link>
            <guid isPermaLink="false">https://medium.com/p/49d494f5116b</guid>
            <category><![CDATA[operating-systems]]></category>
            <dc:creator><![CDATA[Isuruni Rathnayaka]]></dc:creator>
            <pubDate>Fri, 27 Aug 2021 06:20:00 GMT</pubDate>
            <atom:updated>2021-09-07T20:37:21.513Z</atom:updated>
            <content:encoded><![CDATA[<h4>The Road to User Mode</h4><p>Now that the kernel in our developed operating system boots, prints to screen and reads from keyboard. But we still have quite a way to go until the our OS can execute programs in user mode, so this chapter we will witness how to execute a small program in kernel mode.</p><p>If you haven’t read the fifth article of the series on Interrupt handling and reading inputs from keyboard, you can read it from <a href="https://isuruni-rathnayaka0508.medium.com/develop-your-own-x86-operating-system-os-6-68605f50d522">here</a> as its important to have a comprehensive understanding about this continuous process of developing your own operating system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*y0mE7sePifhO93dL.png" /></figure><p>A process is a program under execution from RAM and comprises of various sections: Executable instructions, stack, heap and State. The user process cannot assess the kernel region. System Calls are a set of functions that a OS supports and a user process can use a system call to access the Kernel. When a system call is invoked the processor shifts from user mode to kernel mode.</p><p><strong>Kernel Mode</strong></p><p>In Kernel mode, the executing code has unrestricted access to the underlying hardware. It can execute any CPU instruction and reference any memory address. Kernel mode is generally reserved for the lowest-level, most trusted functions of the operating system. The kernel creates the proper abstractions (for memory, files, devices) to make application development easier, performs tasks on behalf of applications (system calls) and schedules processes.</p><p><strong>User Mode</strong></p><p>User mode, in contrast with kernel mode, is the environment in which the user’s programs execute. In User mode, the executing code has no ability to directly access hardware or reference memory. Most of the code running on the computer will execute in user mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/285/1*ETsRR6uHnfN7R9P-8tSF2Q.png" /></figure><p>Our OS can not execute programs in user mode yet, but with this article let’s get to know how we can execute a program in kernel mode.</p><h3>Loading an External Program</h3><p>Here, we have to somehow load the code we want to execute into memory. But the problem is the place, where we can get the external program from. More advanced operating systems usually have drivers and file systems that enable them to load the software from a CD-ROM drive, a hard disk or other media.</p><p>Without creating all these drivers and file systems, here we will use a feature in GRUB called modules to load the program.</p><h4>GRUB Modules</h4><p>GRUB modules are the arbitrary files that the GRUB can load into memory from the ISO image. In order to load a module using the GRUB, update the file <em>iso/boot/grub/menu.lst</em> in your working directory that we created in an earlier article and add the following line at the end of the file:</p><pre>module /modules/program</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*gk-2YN2zBYjZ5DYFdQdMqg.png" /><figcaption>“Now your menu.lst file will look like this”</figcaption></figure><p>Now create the folder called iso/modules with the below command using the terminal:</p><pre>mkdir -p iso/modules</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*5WT_x0JWCDxagimYYQWVvA.png" /><figcaption>“In iso folder you will see modules folder now”</figcaption></figure><p>The multiboot header exists to allow a bootloader ( GRUB) to load the kernel to whom the header belongs in a way that that kernel expects. The multiboot header also includes the Multiboot magic number which allows GRUB to find the location of the multiboot header. Information in the header will either change how the kernel will be loaded into memory or request that the kernel would like some extra information. The code that calls <em>kmain</em> must be updated to pass information to <em>kmain</em> about where it can find the modules. We also want to tell GRUB that it should align all the modules on page boundaries when loading them. To instruct GRUB how to load our modules the “multiboot header”, the first bytes of the kernel must be updated as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/43950ca4216f19d465d2d65959b931df/href">https://medium.com/media/43950ca4216f19d465d2d65959b931df/href</a></iframe><p>GRUB will also store a pointer to a <em>struct</em> in the register <em>ebx,</em> that describes at which addresses the modules are loaded. Therefore, you want to <em>push ebx</em> on the stack before calling <em>kmain </em>to make it an argument for <em>kmain. </em>Update your loader.s file with the <em>push ebx</em> and above code as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sg57_2PfAGM902HnhwFZ5A.png" /><figcaption>“Now your loader.s file will look like this”</figcaption></figure><h3>Executing a Program</h3><p>In this section, let’s see how we can execute a program.</p><h4>A Very Simple Program</h4><p>As a test program let’s consider a very short program that writes a value to a register. This is an example of such a short program:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8875f7bf27d1657777c00409ad23d2aa/href">https://medium.com/media/8875f7bf27d1657777c00409ad23d2aa/href</a></iframe><p>Create <em>program.s</em> file inside the iso/modules folder and save the above short program in it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UVHPir4QakqOgdoBjvfxVg.png" /><figcaption>“Now you will see program.s file in iso/modules folder”</figcaption></figure><p>Our kernel cannot parse advanced executable formats, so we need to compile the code into a flat binary. NASM can do this with the flag<em> -f</em>. Use the below command on your terminal for that:</p><pre>nasm -f bin program.s -o program</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*tMRovfSghpvz9PbjO_KrWQ.png" /><figcaption>“Now you will see program file in iso/modules folder”</figcaption></figure><h4>Finding the Program in Memory</h4><p>First we must find the place where our program resides in memory. Assuming that the contents of <em>ebx</em> is passed as an argument to <em>kmain</em>, we can do this from C. The pointer in <em>ebx</em> points to a <em>multiboot</em> structure. let’s create multiboot.h file which describes the structure.</p><p>You can use the following code for it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c564a11b0aefb71d0b0f9cf8822aabf7/href">https://medium.com/media/c564a11b0aefb71d0b0f9cf8822aabf7/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cb5AUCDc3lIwTpankgZEZQ.png" /><figcaption>“You can see multiboot.h file in your working directory with the saved code”</figcaption></figure><p>The pointer passed to kmain in the ebx register can be cast to a <em>multiboot_info_t</em> pointer. The address of the first module is in the field mods_addr. The following code can be used for that:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6c75e51d0fa66e074cd4fb3585dac41e/href">https://medium.com/media/6c75e51d0fa66e074cd4fb3585dac41e/href</a></iframe><p>Update your kmain.c file as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*hPKbIWLANrZ3IF0Vpe-Xmg.png" /><figcaption>“Finally your kmain. file will look like this”</figcaption></figure><p>You should always check whether the module has been loaded correctly by GRUB. For that check the <em>flags</em> field of the <em>multiboot_info_t</em> structure. Use the following code for it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa5093d5e8d95ce98160437f8f31da6c/href">https://medium.com/media/aa5093d5e8d95ce98160437f8f31da6c/href</a></iframe><p>You should also check the field mods_count to make sure it is exactly 1, using the following piece of code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ee653159a713fff1977844667d60534e/href">https://medium.com/media/ee653159a713fff1977844667d60534e/href</a></iframe><h4>Jumping to the Code</h4><p>Finally let’s jump to the code loaded by GRUB. This can be done with <em>jmp</em> or<em> call</em> instructions in assembly. But as always it is easier to parse the multiboot structure in C code than assembly code, calling the code from C is more convenient. The C code could look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c7e6f5f8ca132b31d9d8a5397408855/href">https://medium.com/media/9c7e6f5f8ca132b31d9d8a5397408855/href</a></iframe><p>Update your kmain.c file with the above C code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*SKRPvhYgHsyJ81EWGDSX7w.png" /><figcaption>“Finally your kmain.c file will look like this”</figcaption></figure><p>Now, boot your OS using the “<em>make run</em>” command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*99VM2s2QyJmXifIltchEbw.png" /></figure><p>Halting Bochs after a while and then display Bochslog.txt using “<em>cat bochslog.txt” </em>command on the terminal to check whether the register contains the correct number. If you see 0xDEADBEEF in the register EAX , then your program has executed successfully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*nJthYWqeWcLjz338PGeiXQ.png" /><figcaption>“EAX = deadbeef”</figcaption></figure><p>So, now you have executed a small program in the kernel mode.</p><h3>The Beginning of User Mode</h3><p>The program we’ve written in this article runs at the same privilege level as the kernel. To enable applications to execute at a different privilege level (User mode) we’ll have to do <em>paging</em> as well as <em>page frame allocation</em> besides segmentation, which we discussed in an earlier article.</p><p>In the next article we will come across with an introduction to virtual memory and paging, which will lead the path in obtaining, “working user mode programs”. You can read that article from <a href="https://isuruni-rathnayaka0508.medium.com/develop-your-own-x86-operating-system-os-8-78a25b945dde">here</a>.</p><p>References</p><p><a href="https://littleosbook.github.io/">LittleOSBook</a></p><p><a href="https://wiki.osdev.org/Writing_GRUB_Modules">Grub Modules</a></p><p>Hope you understand steps in executing a program in kernel mode. Let’s meet with the next article of Develop Your Own x86 Operating System(OS) series. Thank you so much for reading!!!!!!!!!!</p><p>Isuruni Rathnayaka</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49d494f5116b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>