<?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 Rupali Sharma on Medium]]></title>
        <description><![CDATA[Stories by Rupali Sharma on Medium]]></description>
        <link>https://medium.com/@rupali-sharma?source=rss-52142afe681c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1k1HlrTafAL-7hfYQ23l9A.jpeg</url>
            <title>Stories by Rupali Sharma on Medium</title>
            <link>https://medium.com/@rupali-sharma?source=rss-52142afe681c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 13:17:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rupali-sharma/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[7 Big Lessons of Product Management]]></title>
            <link>https://medium.com/swlh/7-big-lessons-of-product-management-96e824788e32?source=rss-52142afe681c------2</link>
            <guid isPermaLink="false">https://medium.com/p/96e824788e32</guid>
            <category><![CDATA[leadership]]></category>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[product]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[great-product-manager]]></category>
            <dc:creator><![CDATA[Rupali Sharma]]></dc:creator>
            <pubDate>Mon, 18 Jan 2021 11:00:09 GMT</pubDate>
            <atom:updated>2021-01-27T02:58:24.746Z</atom:updated>
            <content:encoded><![CDATA[<h3>7 Big Lessons of a New Product Manager</h3><p>There are many articles on how to get into product management (yeah, I wrote <a href="https://medium.com/@er.rupali/framework-to-break-into-product-management-d9c5c480c8a6">one </a>too). But, there is very little written about a new product manager’s journey or the learnings from the initial few years of being in a product role.</p><p>The remit of the product manager role differs depending on the product, the team, and the company. So when we join a new team as a product manager, we’re learning to fly while also building the airplane.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9zQmPbHC9x6-kUUvljxumw.jpeg" /></figure><p>Here are my 7 big lessons from the past (almost) one year as a product manager in a rapidly growing team, building a product from the ground up.</p><h4>#1. Stay Curious</h4><p>You’ve done courses, podcasts, reading, etc. to successfully get hired as a product manager, right? But like parenthood, there are always things you understand better on the fly, yeah right, because every baby is different. It’s very rewarding to always stay curious, open to understanding perspectives, and asking questions on Why’s and What If’s? All the ace product folks and amazing leaders I’ve come across are super curious, question a lot to understand perspectives, and are flexible to change their opinion in favor of the product. This is a lifelong skill, and is super-critical for any new role. There are two big wins here:</p><ul><li><strong>Become a Better Leader</strong> — Everything is what it is because of a reason, everyone is what they are because there is a perspective. The better we understand these reasons and perspectives, the more accurate picture we can paint every time. This ability to paint a true picture makes us a better leader in the short as well as the long run.</li><li><strong>Better Decisions </strong>— One of the most powerful tools of a product manager is the context. The more we understand the context, the better decisions we make. And the easiest way to understand everyone’s context is by asking questions and staying updated with everyone’s mental models.</li></ul><p>What kind of questions can we ask? Here are some examples:</p><ul><li>What is the thought process in making this decision or taking this direction?</li><li>What inspired you to make this decision?</li><li>What if we do this &lt;my suggestion&gt;? Will there be any concerns to address?</li><li>Why is this important to you (the stakeholder)?</li></ul><h4>#2. Sharing Context is a Job</h4><p>As much as understanding other’s context is important, sharing your own context is equally critical. This puts your perspective on the same table. Also, it enables the opportunity to use the wisdom of the group/team. There are two types of context sharing:</p><ul><li><strong>Sharing the context with your team</strong> — Always remember, “All great ideas can’t come from your head just because you’re the product manager”. Part of the job is to also empower the team members with the context from marketing, partners, etc. and discuss the possibilities. It’s amazing to see how all the self-driven engineers get fueled up, and by the end of the day, new and better ideas surface out. Besides, it establishes the right intention to the team. The right intention helps them to better absorb the jolt of change in product direction/strategy/feature sets, if any.</li><li><strong>Sharing the context with partners</strong> — Working with partners can be challenging because they are not involved in the day to day developments. As a product manager, we filter out the relevant updates and share with the partners regularly to paint the clear picture for them. All in all, it helps minimizing any surprises and build great relationships.</li></ul><h4>#3. Leverage Your Strength</h4><p>I said in my previous <a href="https://medium.com/@er.rupali/framework-to-break-into-product-management-d9c5c480c8a6">blog</a>, in a product role</p><blockquote>Deep expertise in one of the areas is good enough, what really matters is the passion for all three.</blockquote><p>So, identify where do you have in-depth expertise — UX, Tech, or Business? Use your strength as much as you can because the product is really going to benefit from it. In my case understanding technology comes easy to me. This skill has really fueled deep and valuable collaboration with the engineering. Let me give an example. So this once, we had a situation (to be honest, there were many of those kinds), when the engineers discovered technical complexities that had challenging implications. As I listened to the technical discussions and could make sense of it, I quickly realized the product requirement can be loosened a bit. It led to a quick resolution and created a win-win at an early stage.</p><p>The point is — while you’re working on your areas of potential growth, don’t forget to leverage your strengths.</p><h4>#4. Product be the Focus, ALWAYS!</h4><p>It may sound trivial, but this is what distinguishes an ace product manager from a good one. It’s very common as a PM when you’re dealing with vastly different voices — as in engineering wants one thing, the partners want another, and so on. It’s a skill to crack on how to push for the appropriate priorities without panicking, yet maintaining relationships. Yes, it can get stressful. Look at every such situation as your growth opportunity. Making the product the epicenter of the conversation works great in easing out the burden.</p><p>Keep in mind to keep distractions off the bay. Here are some examples of distractions that can be there:</p><ul><li>Many feature requests — Especially if there are a lot of partners, it’s not uncommon to get overwhelmed with a lot of feature requests. What works well is good prioritization by quantifying the impact on the product goals, and alignment with the product strategy.</li><li>Difficult people — We as humans get easily distracted by emotions and it affects each of us to different extents. I learned to always remind myself to bring the focus back to the product and the business goals. Keeping one’s ego low helps for sure in being persistent about your asks. I’d say, usually people can be difficult because they have their own insecurities. The organizational system takes care of it most of the time.</li><li>Your own insecurities — Let’s be real, everyone has insecurities. How to constructively manage these insecurities is an entirely experiential learning. At times, its really liberating to say and normalize phrases like: “I don’t know, let me get back to you on this” or “I realize I had a different understanding, and now what you’re saying makes sense”.</li></ul><h4>#5. Be the Expert of thy Product</h4><p>You’ve probably heard that many times, and know this. Let’s take a step back, and ask ourselves what does an expert on the product mean? Does it mean you know every little detail of the product and the market? Not really.</p><p>The most crucial part of the expertise is to be a product storyteller, an evangelist who can talk to anyone in the world about any dimension of your product. Depending upon product and organization, as a product person, we drive conversations with the team and stakeholders. It’s important you know your audience and tell an exciting product story to make everyone fall in love with your product and its vision. That’ll rally everyone in the same direction to make the product successful.</p><p>Being an expert of product also means, PM is best positioned to see and anticipate the gaps. Either fill in the gap, or call it out to the right folks. A PM should ensure no gaps are left unfilled to drive the product’s success.</p><h4>#6. Think Big, Start Small</h4><p>For some reason human minds have a huge bias towards making perfect plans and perfect solutions. I learned -</p><blockquote>“Perfect can be an enemy of Good.”</blockquote><p>Never underestimate the power of starting small, simple or scrappy. It definitely depends on what phase the product is in. In my case, where we pretty much started from scratch — we have big hairy goals. It’s important that we clearly define our goals where we are thinking BIG. Alongside we have a clear path to reach there by starting small and simple, focusing on a specific user segment. On every step that we Build, we Measure, Learn and let the product grow organically in multiple iterations. This approach has two huge merits: one, it gives a much faster time to market, and second, it enables us to use the live user feedback in making the product better over time.</p><h4>#7. Never Stop Learning</h4><p>Lastly, know to continue the product learning and keep evolving your product mindset.</p><p>We are surrounded by a lot of successful products, and every story is slightly different than each other, with its own unique set of learnings. Product Management as a concept is expanding in many dimensions every day. It’s valuable to never stop learning. Thankfully we have a lot of ways in the current world — reading books or blogs, listening to podcasts or audio-books, conversations with other product minds at meetups, conferences, etc. I’m guessing you’re really good at learning (as you’re here reading this).</p><p>I’m more into reading books. I’ve come to a realization that reading a great (non-fiction) book is like a journey we take with the author. During this journey, we see our current existence through the lens of the writing. It isn’t much about gaining knowledge, it is more about contemplating our present life situations. In the end, we evolve through this inspiration and ideation machine (i.e. the book being read).</p><p>One caveat is, there is a concept called information overload. So just be mindful of what and how much you’re consuming. Too much of anything is usually a bad idea.</p><p>Thanks for reading, and hope you found these 7 lessons valuable. I’d love to hear your thoughts and product experiences as well. You can comment below. You can also connect with me on Twitter <a href="https://twitter.com/rupali_sharma">@rupali_sharma</a>, where I share my thoughts and active learnings frequently.</p><p>Spoiler alert — I’ll also share about lego mechs that I build with my kid.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96e824788e32" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/7-big-lessons-of-product-management-96e824788e32">7 Big Lessons of Product Management</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Framework to break into Product-Management]]></title>
            <link>https://rupali-sharma.medium.com/framework-to-break-into-product-management-d9c5c480c8a6?source=rss-52142afe681c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9c5c480c8a6</guid>
            <category><![CDATA[framework]]></category>
            <category><![CDATA[career-change]]></category>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[career-transitions]]></category>
            <category><![CDATA[product-manager]]></category>
            <dc:creator><![CDATA[Rupali Sharma]]></dc:creator>
            <pubDate>Mon, 25 May 2020 23:23:42 GMT</pubDate>
            <atom:updated>2021-01-22T05:15:57.525Z</atom:updated>
            <content:encoded><![CDATA[<p>Here is a framework to craft one’s unique transition journey into product management. I’ve shaped this framework based on my set of learning and reflections from my personal transition journey from engineering to product. The framework focuses on building the right set of skills to become and thrive as a product manager.</p><p>Let me share a bit about myself and why I’m writing this article. I started my career as a software developer and engineered products for 11+years. I had a pivotal moment in my life when I self-acknowledged that I want to do product management. In about a year I was able to successfully transition to a full-time product role.</p><p>I’ll be honest, the transition journey was challenging, especially because I had been doing something else for more than a decade. The challenges pushed me to methodologically approach my aspirations.</p><p><em>“Excitement comes from achievement. Fulfillment comes from the journey that got us there” — Simon Sinek</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fujtZjcKo-OS7qQl.jpg" /><figcaption>Courtesy <a href="https://picsart.com/i/image-create-your-own-path-freetoedit-road-path-camino-286991566027201">https://picsart.com/i/image-create-your-own-path-freetoedit-road-path-camino-286991566027201</a></figcaption></figure><h3>The Framework</h3><p>Many people have asked me ”What is the mantra for breaking into product management?” I believe there is none. Like a story, every individual has a scene to begin with, and a unique set of challenges. The right question to ask is how do we map out our career transition journey from point A to B, and be successful at B? Here is a framework to best define a successful journey:</p><ol><li>Assess yourself</li><li>Assess the gaps</li><li>Build a plan</li><li>Work and Persevere</li></ol><p><strong>Opportunity hypothesis — Assess yourself</strong></p><p>Start with self-assessments and reflections, which are immensely powerful. They give us a clearer understanding of who we are and what sparks joy in us. The four fundamentals I focused on are:</p><ul><li>My strengths</li><li>My values</li><li>The sense of happiness</li><li>My trigger points</li></ul><p>The above self-data points may not fully define you because we as sapiens are evolving species. It serves the following two purpose:</p><ol><li>Surfaces the deep-rooted reasons as to why you want to be a product manager. It’s a commonly asked question when you’re out in the job field. Your crystal clear thought process will reflect in your storytelling and will bring a spark in your eyes, which many leaders love to see. In my personal experience, as I was working to transition internally and capitalize on the trust and credibility that I built as a developer, my team wasn’t ready to let me go. I was doing a 20% PM role as a side-project, and getting great feedback but still was constantly told to focus on the dev work. I could empathize with my team who had an herculean goal to achieve, but at the same time, I couldn’t see myself dragging my ambition. Fortunately I got an opportunity to talk to a C-level executive to share my passion and spark. From there on, I witnessed extraordinary leadership which will inspire me always.</li><li>Brings a sense of comfort about yourself. During all the several moments of feeling-low, a strong self comes to the rescue. There are gazillion different kinds of humans that we meet every day, and more than half will be super difficult to deal with while you are at the receiving end. The most needed attribute during this journey is being comfortable in your skin. Trust me, it helped me build resilience.</li></ol><p><strong>Problem Definition- Assess the gaps</strong></p><p>Let’s be diligent in assessing the gaps that need to be worked on. Product management is at the intersection of the following three.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*djXSa5Heunq7ejj0" /></figure><p>Deep expertise in one of the areas is good enough, what really matters is the passion for all three.</p><p><strong>First</strong>, look at the spectrum of the product management role and find out, what kind of product manager you want to be:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*exG3H8LUaEp9T4heNmVcEw.png" /></figure><p>A general Product manager usually lies in the center. Fortunately, I was able to test the waters by doing a couple of flavors before I moved into a full-fledged Product Manager role. I’d recommend the same if that’s a possibility. Another aspect is to figure out what type of product you want to work on? I’d strongly suggest going for the same type of product you’ve been working on which will build upon your strength.</p><p><strong>Second</strong>, learn about the expectations for the kind of product manager you want to be. I have two suggestions:</p><ol><li>Talk to the PMs out there, as many as you can. In my experience, it was really easy to reach out to people for coffee chats as everyone loves to talk about themselves and their work. Equally important is to take a selected few conversations forward and get mentors. I got four valuable mentors and sure, having multiple mentors played out extremely well.</li><li>Reach out to the hiring managers, and understand their expectations. My favorite question to ask was — “Who is an ace product manager for you?” The response also gave me some notes on what to highlight about myself during the real interview.</li></ol><p><strong>Third</strong>, articulate the biggest challenges that you foresee or are facing in making the transition. These challenges are what’ll make your transition story unique to you. For example, I was looking to transition internally and was working on a highly visible and critical project. A lot of leaders in my org were constantly telling me to focus on the dev work. My biggest challenge was to stand strong on what I wanted and not burn any bridges. Reason being as a Product Manager, I’d be working with the same folks as my partners.</p><p>Use the following model to jot down all the skills and challenges:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*LiC719NoFrnbzUXyW49rNA.png" /></figure><p>Through this exercise, I identified certain stereotypes attached to a developer that I had to face. Many people assumed I had no experience of public speaking or cross-functional partnerships, as I must have been doing heads down coding all day and night. My reality was different, so these were the skills I jotted down as the skills I needed to highlight.</p><p><strong>Solution space — Build a plan</strong></p><p>The gaps and challenges are better known now. The next step is to build a plan to bridge the gaps and overcome the challenges. Building a plan can be anything from doing a product tear-down to trying a business idea. I highly recommend discussing the plan with your mentors too. Happy to share the 4 plans from my diary.</p><ul><li>Product Assignments</li></ul><p>The idea is get product assignments in the form of specific product requirements, competitive analysis or even backlog management.</p><ul><li>Speaking opportunities</li></ul><p>Presenting decks is one of the most glamorous and desirable skills in a product manager. My mentor advised me to create speaking opportunities for myself. One of the ways to put yourself on the spot is to pick a product relevant to your current industry, and present a tear down. Through this, you can showcase your product thinking and your presentation skills.</p><ul><li>Learning</li></ul><p>The intention here is two-fold. First is to learn the product management basics and work on the identified gaps. For example, if you feel data analytics is foundational for the product role you are looking for, take a course. To thrive in your future role, it’s important that you understand the basics. The second intention is to establish your interest. When I enrolled in a product management course from Product School, I made sure to talk about it to all the PMs I was talking to. It accentuates the seriousness about the transition, and establishes the interest, that you are here to learn and work it through. Not just courses, I’d encourage you to evolve yourself through reading books, blogs or listening to podcasts. I made a list of books and a few podcasts as part of my plan as well.</p><ul><li>ERGs and Outreach programs at work</li></ul><p>I made it my annual goal to lead ERG initiatives at work. It’s a great way to demonstrate one’s leadership skills and experience execution of ideas resulting in a huge impact. It does extract considerable time bandwidth, and in my opinion that is totally worth it. As a bi-product, I made amazing friends and a very supportive tribe to surround myself with.</p><p>Other examples of ideas in the plan could be:</p><ul><li>Taking a hobby to the next level</li><li>Joining a nonprofit’s leadership team</li><li>Kickstarter project</li></ul><p>Caveat — don’t spend too much time in making a perfect plan, rather just have one and keep iterating over it. The good action plan is a live document that is meant to evolve.</p><p><strong>Execution and Iterations — Work and Persevere</strong></p><p>Working on the plan isn’t as easy as it may sound. The most important skill here is to navigate through the opportunities. There may be times, when multiple threads of side-initiatives are running in parallel. Not to forget, most likely you have a full time job that you’re most accountable for. This is an opportunity to rehearse prioritization, which you’ll have to do plenty once you are in a product role.</p><p>Depending on your company dynamics, you may encounter some futile executions. In my case, I was continuously talking to PMs in my team and wider organization and looking to get a side project. Every product manager I talked to was drowning in work, still, it was hard for anyone to give me a small piece. Putting myself in their shoes, I feel it’s more about managing accountability than being generous. I figured the right approach is to offer help rather than asking for work. It’ll be relatively easier if you offer yourself to the PM in your team, as there will be less of a learning curve (and you wouldn’t be a huge time sucker). Through this route, I successfully grabbed an assignment of writing the product requirement for a very low priority feature.</p><p>Be precise and clear in the asks also leads to better results. I was also very clear in sharing my intention to my mentors and my manager. Since the leadership team has a much better idea of the wider scheme of things, they could help me direct to the right opportunity. Eventually my mentor played a big role in having me pick a run-the-business product which was destined to deprecate as my 10% project.</p><p>As I reflect now, the core elements which I leveraged as I made my way up to a full-time role are:</p><ul><li>Trust — Relationships build over trust. A lot of effort goes into building trust, and it’s totally worth it.</li><li>Perseverance — Tangible outcomes take time, and in this time, frustration and dejection are detrimental to our success. Things were developing which I couldn’t see, but thankfully I kept giving my 100% to all the work I was doing.</li><li>Communication — The smart work speaks for itself — False! It’s equally essential to talk about your work and capitalize on your interactions.</li></ul><h3>In the End</h3><p>As humans, we have a huge bias towards action. Huge learning is that a successful career transition journey starts with assessing oneself mindfully. With the right mindset, assessing the skills and challenges leads to a powerful actionable plan. The execution might be a roller coaster ride, but that’ll ensure you build the right skills and be an ace product manager.</p><p>Hope this write up is helpful to you and you take home the following:</p><ul><li>A framework to break into product management.</li><li>Tools to systematically build the career transition plan</li><li>Positivity and inspiration to power through the transition journey</li></ul><p>Thank you for reading and if you find this useful, please feel free to share with your friends who are in the same boat. My goal is to reach out to a much wider audience and hopefully they can embark on a much shorter and equally fulfilling journey than I did.</p><p>I’m on <a href="https://twitter.com/rupali_sharma">twitter </a>and of course on <a href="https://www.linkedin.com/in/rupali-sharma-171a757/">linkedin</a>.</p><p>Wish you all the best!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9c5c480c8a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Grace Hopper Experience]]></title>
            <link>https://rupali-sharma.medium.com/after-months-of-anticipation-and-excitement-the-grace-hopper-celebration-came-and-flew-by-91be1edf120e?source=rss-52142afe681c------2</link>
            <guid isPermaLink="false">https://medium.com/p/91be1edf120e</guid>
            <category><![CDATA[women-in-tech]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Rupali Sharma]]></dc:creator>
            <pubDate>Sat, 14 Oct 2017 07:02:45 GMT</pubDate>
            <atom:updated>2017-10-17T23:32:18.188Z</atom:updated>
            <content:encoded><![CDATA[<p>After months of anticipation and excitement, the Grace Hopper Celebration came and flew by. Yes, I was one of the 18 thousand attendees at Grace Hopper Celebration (GHC), which happened from October 4 to 6, 2017 in Orlando Florida. The three days were packed with overwhelming keynotes, informational sessions, networking, selfies and some profound discussions. I am deeply grateful for this opportunity, as I feel I came out a completely different person than what I went in as. Therefore, here I am, to pen down my exhilarating experience at GHC 2017 as the zeal and the hyper positivity might dissipate in the friction-ful environment.</p><p>Before I percolate through my key highlights from the celebration, I want to share my reflection on why do we need such kind of events where diversity &amp; inclusion is heavily targeted in the technical industry. That leads to a question, on why diversity is so important as we advance the wheel of innovation and the evolution of ideas into the space. Well, we need diversity, to bring different perspectives on the table, while we solve problems everyday. I will call out, true diversity incorporates people of all genders, from different cultures, of all colors and also from different professions and interests.</p><p>Now because technology benefits from diversity, it comes with a responsibility to create and retain an open and inclusive cultures to work in. One of the most effective tool is building allies which offers mentorship, inspirations and a safe place to expose one’s vulnerabilities. That is exactly what such diversity focussed conferences cater to i.e. a place to find our tribe!</p><h3><strong>Highlights from my lens:</strong></h3><p>Day 1’s excitement was worth witnessing with 18k techies encompassing all kinds of similarities and differences, however all passionate about one thing — Solving Problems! I talked to people from different walks of life from various companies. The topics ranged from why python is the favourite language for machine learning, to, what Amazon is doing to blend Whole Foods in.</p><p>I was super elated (read lucky) to be able to find a seat in the hall for the keynote, considering the fact that the seating capacity was 6k less than the total attendees.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Zoh4zw-63haaoK_I." /></figure><p>Yes you got it right! I m trying to brag a little about how close I was to the podium! :D</p><p>The keynote was phenomenal. It started with a talk by <strong>Dr Fei Fei Le</strong>, professor and director at Stanford AI Labs on basics of machine learning. She talked about how machine learning is ramping up to recognise emotions in a static image. More than the technology, it was about values and emotions recognized by Artificial intelligence. It was a completely a new perspective, about how diversity in all respects is paramount in the field of machine learning, as humans are trying to map human values into machine values. In her words,</p><blockquote>“The future of AI should not just benefit us all, it should reflect us all”</blockquote><p>Dr Fei Fei also shared her life story and talked about her challenges as an immigrant in United States during the early phase of her career.</p><p><strong>Diane Greene</strong>, a founder of three startups and the Technical Leadership ABIE award winner, talked about her childhood experiences that how steering boat on rough waters has shaped her. She shared how she started Vxtreme — a streaming software, and VMWare, and BeBob. <strong>Megan Smith</strong> — Former CTO with President Obama, apprised us about how much effort and streamlining has been going undercurrent to upgrade the tech culture.</p><p><strong>Melinda Gates</strong> — Co-chair, Bill &amp; Melinda Gates Foundation, provided insights on different paths and opportunities that can be created to involve more and more diverse groups and interests in technology.</p><blockquote>“For girls growing up, let’s create plenty of pathways to explore tech — inside and outside the classroom,” she said.</blockquote><p>I’d say the keynotes were overwhelming and highly motivational, as I heard remarkable leaders and the stories of ABIE award winners. I couldn’t believe myself that I did so much of productive listening that day, and it was just the beginning.</p><p>Here I am, super excited with the quote : She’s in the game! (apologize, the quote should be mindful of including all gender identities)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*TY1WMM4kIPL2usWR." /></figure><p>I was pumped up to attend three more technical sessions on the future of AR/VR in gaming, on some Media Interactive Researches and on the Recommendation Systems by Linkedin and Microsoft. One interesting concept I came to know was game-automators, which are aimed at making learning fun. (Check out <a href="http://gameautomators.com/">here</a> )</p><p>Day 2 again, had an incredible start with keynotes. The major highlight story of the hour was a talk by <strong>Debbie Sterling</strong>, Founder and CEO of Goldieblox. Debbie created a set of toys for girls with focus on building interest and confidence in engineering. It wasn’t even a technical product, but the story and her story-telling was so powerful.</p><blockquote>“Engineer must be in a girl’s dictionary!” Debbie mentioned.</blockquote><p>Believe it or not, 99% percent (or probably 100%) of the women I talked to, after the keynote, were in the awe of the Goldieblox story.</p><p><strong>Dr. Sue Black</strong>, an ABIE award winner for Social Impact, who took the show away by her inspiring story on how she found #techmums.</p><p>After the keynotes, rest of the day I was at the Open Source Day, which was pretty enthralling. It was kind of a hackathon, which I wanted to experience. I got an opportunity to work with 5 extremely talented women, two of whom had flown all the way from Germany for this event. It was amazing to learn some pieces of the OpenShift by RedHat, and to have an email notification functionality working, for our application to donate volunteering resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xoHPOmOSxzt6riHS." /><figcaption>Keynote speaker Ayanna Howard, Robotics Researcher at Georgia Tech, talking about Robots.</figcaption></figure><p>Day 3, I attended some marvelous sessions on ‘Going beyond women in technology’ and ‘Riding the change in technology’. If you have learnt algorithms at any stage of your life, then you definitely know <strong>Thomas H Cormen</strong>. Yes, the honorable Cormen and his well acclaimed books which taught me algorithms. I couldn’t resist jumping seeing him at the conference. I talked with Thomas Cormen and heard his views on what brought him to GHC 17.</p><p>The keynotes in the evening again came out making the best of the memories. I got insights about robotics and how important it is to control human biases as we teach robots our values. I also saw some social experiments, where people unconsciously believed the robots knew better than them. The very fact is so fascinating.</p><h3><strong>The Expectations</strong></h3><p>I’ll be frank, when I registered for Grace Hopper, I was expecting to learn what different companies are doing? I was expecting to come back with lots and lots of technical know-how and build a network, to be part of more communities and expand myself horizontally.</p><p>One of the reasons my experience was extraordinary was that I was under-expecting. All the technical sessions I attended, none of them had any wait time to get into, rather all the houseful sessions read like “Learning how to negotiate”, “Riding the change in Technology”, “Learn to get your voice out”. The very fact was very intuitive to me. It was eye-opening that I am not the only one who is struggling with these concepts, Neither was I alone in hunting for cues to mould into an influential(or sassy as you may call) technologist!</p><h3><strong>My context and the learnings</strong></h3><p>When we listen to a talk, we all interpret it differently, because we all are like buildings made with assortment of blocks, where each block is a unique experience of our life. What I learnt from this 3 days GHC might be an entirely different perspective from what the person sitting next to me might have perceived. Therefore, I think it’s important to provide a little context about myself.</p><p>I identify myself as a woman. I grew up in a culture where a born child is not celebrated, because she is a girl. I am here, because my parents believed in me and the society around mocked at us. So as you can tell, I turned out rebellious when it comes to traditions and societal pressures. Still these are like battles, rather worthless battles which takes some energy to ignore. I have been the only female developer in the team, for more than half years of my professional life and for some reason, been bullied by the male members of my team during the early phase of my career. However, I was too naive to identify it. Besides, I am a mother, rather a single mom for 2–3 days of the week, and that’s it!</p><h4>Share your Story</h4><p>You must be thinking, why I am telling mostly the unpleasant stuff of my life, when I could have summarized my context in one line. That’s my very first learning, — to share my story, and share my struggles which I just did. It is extremely powerful to share one’s story. I am so guilty of suppressing myself of talking about my personal battles and keeping my emotions to myself. When in this world, each of one us is struggling to achieve BIG, it’s so important to share your part. The power lies when someone, someone out there, may connect to my story and learn from my experiences and my mistakes. The successful people I’ve admired the most are those who have given back to the community at every possible opportunity. I don’t have to be influential enough or with a huge set of followers, but if I have something to give hope and ignite a single heart, that’s all worth it.</p><p>And why just story, we should share our knowledge and thoughts, in whatever medium we feel the most comfortable with. I am definitely motivated even to share my silly experiments from my spare time with open source sdks.</p><h4>Build and join communities</h4><p>For the most part of my life, I have believed, that if I am great at what I do, I do my work smartly, it is a necessary and sufficient condition to succeed. No, it might be a necessary condition, but not sufficient. That’s my second big learning. To be a hero doesn’t mean I have to fight all alone. We need to join local communities, and that’s also how we find allies. We are social animals, and we, inherently build communities, where we all want each other to succeed and overcome the hurdles.</p><p>Moreover, I realised we mostly talk about empowerment of women. It’s not just about women! It’s heart-breaking to hear stories of non-binary people and people of color, who have their own unique behavioral attributes. Tiffany Price, one of the the panelist at a session mentioned, that it is part of her identity that whenever she enters a place, she unconsciously counts the people who look like her. I couldn’t connect to it, but could feel how apalling it can be. How can I make difference in her situation, is by acknowledging how she feels and try to have more friends like her in my life, so that they feel part of the society, which they already are.</p><p>Giving support doesn’t mean we have to do favours for them at work, it just means we acknowledge someone has a disparate life and history than us. Acknowledge the fears and ensure we provide a safe environment to open up. When I became a mother, I was advised to not to talk about my baby or my medical issues at work. Terrible advice! Just terrible! Being a strong person doesn’t mean, we don’t need extra appreciation for the extra energy we have to pull in. I want to do the best thing at work, having another responsibility doesn’t and will never alter my intention. Being a mother gives me the power of sleeping less at night, it gives me tremendous motivation and drive to do great at work and succeed, so that I can become a role model for my child. Remember if you think you are different than people you work with, retain your uniqueness, because you are going to make a BIG change.</p><h4>Embrace failures and find sponsors</h4><p>My third learning, or rather personal observation I would say was about the two most common strings in all the success stories. First, everyone failed more than once in their life, which enabled them to get back much stronger and harder. So we should embrace our failures and use them to weave our success stories. The second commonality was, everyone had a sponsor at some stage of their career, someone who was more experienced and influential to point to the opportunities around them. So we should do the best in whatever work we do, whether we like it or not. People are judging you on your capabilities with how you work and deliver. One of them may open up new hidden doors of opportunities for you. It’s also important to build relationships and retain baseline work ethics.</p><h4>Revolutionary technologies</h4><p>My fourth big take away was learning about how the world is changing and a transformation is in progress as revolutionary technologies are being worked on. I learnt that the machines are capable of learning emotions, how robots are being used in the therapy for children, and how intelligent cameras are discovering new worlds under the ocean and in space. We are living in an extra ordinary time to witness some magnificent milestones in technology. So for all those, working in technical roles, you are here to make a prodigious impact in the world.</p><p>I’ll rest my pen with what Brenda Darden Wilkerson, the new CEO of Anitab.org stated</p><blockquote>“You were put here to do something uniquely… Fear is only the enemy if you give in to it… If you know it’s the right thing to do, go for it and succeed.”</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91be1edf120e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fiddling with Linux processes in memory]]></title>
            <link>https://rupali-sharma.medium.com/fiddling-with-linux-processes-in-memory-f56f62b019c7?source=rss-52142afe681c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f56f62b019c7</guid>
            <category><![CDATA[process]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[memory-management]]></category>
            <dc:creator><![CDATA[Rupali Sharma]]></dc:creator>
            <pubDate>Tue, 15 Aug 2017 00:03:23 GMT</pubDate>
            <atom:updated>2017-08-17T17:20:42.690Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve seen many people using the terms process, thread and program interchangeably. However, under legitimate glossary, processes, threads and programs represent different definitions. Here is my take on it</p><p><strong>Program</strong> : A set of instructions written to perform a specific function(s), which holds memory on the disk.</p><p><strong>Process</strong> : When we run the written program (i.e. the executable, obtained after compiling and linking), it creates its own memory space in the RAM. This running instance is a process. I like to call it a program in action.</p><p><strong>Thread</strong>: Thread is like a building block of a process. A process can have one or more threads running, where all the threads in a process share the same virtual address space and system resources.</p><h4><strong>Processes in Memory</strong></h4><p>Well, we know that a running process occupies memory in RAM. But then what next? how is this memory allocated, and how does it work?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*4jNY_EsI-JezhoV6.jpg" /></figure><p>In this article, I am aiming to get good hold of memory layout of linux processes, which might involve some linux-OS specific concepts and a bit of understanding of memory management. However, I have tried to focus more on fun and experiential learnings.</p><p>While a process is running, it is performing a certain task, and, it may have to use the system resources. A very basic example to illustrate a system resource is a file on the disk. In order to read a file from the file system, it has be accessed. Now, what if another process has to access the same file on the disk? Who will decide whether it should be allowed to be accessed or not? Moreover for all the allowed accesses, it is the operating system, i.e. the linux in our case, which has to manage all the accesses to the file.</p><p>How Linux manages its resources is, it does not allow any user running process to directly access any of the system resource. It offers system calls, which are called from the user space to use the system resources. Only when a process enters the kernel space it can access the file, and the kernel keeps track of the opened files in the form of kernel file tables.</p><p>For reference, system memory in Linux can be divided into two distinct regions: kernel space and user space. Kernel space is where the kernel (i.e., the core of the operating system) executes(i.e., runs) and provides its services.[Reference: <a href="http://www.linfo.org/kernel_space.html">here</a>]</p><p>In memory, every running process is given 4GB of virtual address space considering a 32-bit architecture. The lower 3GB virtual addresses is accessible to the user space portion of the process and the upper 1GB is accessible to the kernel space portion. Following is a diagram illustrating the 4GB process virtual address space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/0*9HZm_lMogTQv9ht2." /></figure><p>The above process memory split of 1GB to kernel space and 3GB to user space is changeable though, as per the need. However, in most of the cases, 1GB/3GB split suits the best.</p><p>Zooming into the user space address memory layout, there are various segments in a process. Following is a diagram to illustrate a picture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/0*C1QG-6JxNYursyVu." /></figure><p>The above diagram is an abstract snapshot of a generic process image in memory. We see the memory has been categorized into various segments in accordance with the ELF format. ELF (Executable and Linking format) is a common standard file format for executables and libraries on unix-like systems. Let us walk through these segments and see what is in store there.</p><p><strong>Text Segment</strong></p><p>The executable binary is mapped onto this text segment and therefore is a read only segment for the process. Basically, this segment contains the instructions to be followed by the processor in a language that the processor understands (machine language :D). Hence this is also called the code segment. In certain scenarios, where multiple processes are created out of the same program, Linux allows sharing of the text segment to avoid reloading the same instructions.</p><p><strong>Data Segment</strong></p><p>This segment cannot be shared among processes. The data segment is internally parted into two areas.</p><p>One part of the segment memory holds all the initialized data variables i.e. initialized global variables or static variables.</p><p>The second part, also called the BSS segment of the process image has the uninitialized data of the program, which includes the global variables which have not been initialized. However, upon the onset of the process, all the data of the BSS segment is zero-initialized.</p><p><strong>Heap</strong></p><p>Whenever the programmer needs to allocate memory during runtime, heap is the segment from which the memory is provided.</p><p><strong>Stack</strong></p><p>The stack contains all the local variables used in the program considering their respective local scopes. Whenever a local variable is defined, it is pushed into the stack and whenever the scope for that local variable ends, it is popped out.</p><p>The stack might be decreasing or increasing in linear addresses depending upon the underlying architecture.</p><p><strong>Shared Libraries</strong></p><p>This is no segment as such. In case we have dynamically linked our program to shared objects, shared objects are loaded at the runtime. This part of memory help the process in mapping and accessing the exposed functions which from the shared libraries.</p><h4><strong>The process stats</strong></h4><p>Now, we are ready ready to see the real memory address numbers in the memory. However, getting down into the memory, it is very helpful if one knows and understands the intricacies of concepts like paging, physical address mappings, etc which is out of scope of this article.</p><p>Nevertheless, I am trying to keep it as simple and broad as possible.</p><p>To begin with, we need to write a code. I just randomly chose a mathematical program which gives us the sum of squares of numbers in a list.</p><pre>const size_t SIZE = 6;</pre><pre>int main()</pre><pre>{</pre><pre>    std::vector&lt;int32_t&gt; list;</pre><pre>    int64_t sqSum = 0;</pre><pre>    int32_t initialVal = 1;</pre><pre>    // Populate the list some random way</pre><pre>    for (uint32_t i = 0; i &lt; SIZE; i++)</pre><pre>    {</pre><pre>         list.push_back(initialVal * i);</pre><pre>    }</pre><pre>    sleep(100);</pre><pre>    //Compute square sum</pre><pre>    for (uint32_t i = 0; i &lt; SIZE; i++)</pre><pre>    {</pre><pre>        sqSum += (list.at(i)*list.at(i));</pre><pre>    }</pre><pre>    std::cout &lt;&lt; “Squared Sum is : “ &lt;&lt;sqSum&lt;&lt;std::endl;</pre><pre>    return 0;</pre><pre>}</pre><p>Well, we have the ‘sleep()’ call in there because, we want the process to be valid for sometime. While the process is sleeping, we want to explore the memory layout of the process before it ends.</p><p>We compile the program and run it in the background.</p><pre>$g++ -g -Wall -std=c++11 squareSum.cpp -o squareSum</pre><pre>$./squareSum &amp;bg</pre><p>To get any information regarding a process, PID is the prime key. Hence, we need to retrieve the assigned PID of our process.</p><pre>$ ps</pre><pre>PID TTY TIME CMD</pre><pre>18009 pts/19 00:00:00 bash</pre><pre>19014 pts/19 00:00:00 squareSum</pre><pre>19095 pts/19 00:00:00 ps</pre><p>In order to get the complete status of our newly created process including the status, size of memory segments, etc, we do</p><pre>$ cat /proc/19014/status</pre><p>Well, this is a command to retrieve data using /proc file system which is a special linux file system providing information about system and processes. We will see, procfs is really helpful in getting more and more about the current processes.</p><p>The output I see on my system is</p><pre>Name: squareSum</pre><pre>State: S (sleeping)</pre><pre>Tgid: 19014</pre><pre>Ngid: 0</pre><pre>Pid: 19014</pre><pre>PPid: 18009</pre><pre>TracerPid: 0</pre><pre>Uid: 1000 1000 1000 1000</pre><pre>Gid: 1000 1000 1000 1000</pre><pre>FDSize: 256</pre><pre>Groups: 4 24 27 30 46 113 128 1000</pre><pre>NStgid: 19014</pre><pre>NSpid: 19014</pre><pre>NSpgid: 19014</pre><pre>NSsid: 18009</pre><pre>VmPeak: 13276 kB</pre><pre>VmSize: 13276 kB</pre><pre>VmLck: 0 kB</pre><pre>VmPin: 0 kB</pre><pre>VmHWM: 1552 kB</pre><pre>VmRSS: 1552 kB</pre><pre>VmData: 280 kB</pre><pre>VmStk: 136 kB</pre><pre>VmExe: 12 kB</pre><pre>VmLib: 4564 kB</pre><pre>VmPTE: 48 kB</pre><pre>VmPMD: 12 kB</pre><pre>VmSwap: 0 kB</pre><pre>HugetlbPages: 0 kB</pre><pre>Threads: 1</pre><pre>SigQ: 0/3797</pre><pre>SigPnd: 0000000000000000</pre><pre>ShdPnd: 0000000000000000</pre><pre>SigBlk: 0000000000000000</pre><pre>SigIgn: 0000000000000000</pre><pre>SigCgt: 0000000000000000</pre><pre>CapInh: 0000000000000000</pre><pre>CapPrm: 0000000000000000</pre><pre>CapEff: 0000000000000000</pre><pre>CapBnd: 0000003fffffffff</pre><pre>CapAmb: 0000000000000000</pre><pre>Seccomp: 0</pre><pre>Cpus_allowed: ffffffff</pre><pre>Cpus_allowed_list: 0–31</pre><pre>Mems_allowed: 00000000,00000001</pre><pre>Mems_allowed_list: 0</pre><pre>voluntary_ctxt_switches: 1</pre><pre>nonvoluntary_ctxt_switches: 0</pre><p>The output gives us a beautiful picture of our process.</p><p>It is fine, if one is not able to understand what each and every value in the output means. The more one plays around and experiment, the more concepts gets absorbed in our minds.</p><p>Although, at the moment it is significant to know the following :</p><p>State: S (sleeping)</p><p>Since, the process is currently having a valid PID, only because of the sleep() call, hence we know the process is sleeping.</p><p>Tgid: 19014</p><p>The thread group ID(Tgid) here is same as the PID of the process</p><p>Pid: 19014</p><p>Nothing new here, we already are familiar with this number.</p><p>PPid: 18009</p><p>The parent ID. In our case, the bash shell is the parent process as we executed the binary from the shell. To confirm, just note the PID of ‘bash’ from the ‘ps’ command output.</p><pre>$ps</pre><pre>PID TTY TIME CMD</pre><pre>18009 pts/19 00:00:00 bash</pre><pre>22228 pts/19 00:00:00 ps</pre><p>VmPeak: 13276 kB</p><p>As the name suggests, it is the peak memory size of the process. It also infers that the memory size of the process keeps on varying.</p><p>VmSize: 13276 kB</p><p>The current size of the virtual memory being used by the process.</p><p>VmData: 280 kB</p><p>The size of the data segment of the process in memory.</p><p>VmStk: 136 kB</p><p>The size of the stack segment of the process in memory</p><p>VmExe: 12 kB</p><p>The size of the text segment of the process in memory is 4KB</p><p>VmLib: 4564 kB</p><p>The size of virtual memory occupied by the shared objects is 1788KB.</p><p>Threads: 1</p><p>The number of threads. Since, we never started any new thread, just the main thread is running.</p><p>If you are interested to learn the complete output of your process, the <a href="http://man7.org/linux/man-pages/man5/proc.5.html">man page</a> is very helpful.</p><h4><strong>The real addresses</strong></h4><p>It’s time to jump into the addresses of the segments of our process. The process segments are also termed as virtual areas in the kernel terminology. Worth mentioning, the addresses we see in this section are all virtual addresses.</p><p>We shall pick up the same squareSum program what we wrote in the previous section.</p><p>Let us create our process and get it running and sleeping :)</p><pre>$./squareSum &amp;</pre><p>We again will use the procfs to get the absolute process virtual memory mapping to each segment. Here is how I do it:</p><pre>cat /proc/&lt;process pid&gt;/maps</pre><p>The memory maps from my system looks like</p><pre>$ cat /proc/25371/maps</pre><pre>00400000–00403000 r-xp 00000000 08:01 262403 /home/parallels/c++/eg4articles/processes/squareSum</pre><pre>00602000–00603000 r — p 00002000 08:01 262403 /home/parallels/c++/eg4articles/processes/squareSum</pre><pre>00603000–00604000 rw-p 00003000 08:01 262403 /home/parallels/c++/eg4articles/processes/squareSum</pre><pre>00df2000–00e24000 rw-p 00000000 00:00 0 [heap]</pre><pre>7f87f7979000–7f87f7a81000 r-xp 00000000 08:01 2888287 /lib/x86_64-linux-gnu/libm-2.23.so</pre><pre>7f87f7a81000–7f87f7c80000 — -p 00108000 08:01 2888287 /lib/x86_64-linux-gnu/libm-2.23.so</pre><pre>7f87f7c80000–7f87f7c81000 r — p 00107000 08:01 2888287 /lib/x86_64-linux-gnu/libm-2.23.so</pre><pre>7f87f7c81000–7f87f7c82000 rw-p 00108000 08:01 2888287 /lib/x86_64-linux-gnu/libm-2.23.so</pre><pre>7f87f7c82000–7f87f7e41000 r-xp 00000000 08:01 2888281 /lib/x86_64-linux-gnu/libc-2.23.so</pre><pre>7f87f7e41000–7f87f8041000 — -p 001bf000 08:01 2888281 /lib/x86_64-linux-gnu/libc-2.23.so</pre><pre>7f87f8041000–7f87f8045000 r — p 001bf000 08:01 2888281 /lib/x86_64-linux-gnu/libc-2.23.so</pre><pre>7f87f8045000–7f87f8047000 rw-p 001c3000 08:01 2888281 /lib/x86_64-linux-gnu/libc-2.23.so</pre><pre>7f87f8047000–7f87f804b000 rw-p 00000000 00:00 0</pre><pre>7f87f804b000–7f87f8061000 r-xp 00000000 08:01 2888414 /lib/x86_64-linux-gnu/libgcc_s.so.1</pre><pre>7f87f8061000–7f87f8260000 — -p 00016000 08:01 2888414 /lib/x86_64-linux-gnu/libgcc_s.so.1</pre><pre>7f87f8260000–7f87f8261000 rw-p 00015000 08:01 2888414 /lib/x86_64-linux-gnu/libgcc_s.so.1</pre><pre>7f87f8261000–7f87f83d3000 r-xp 00000000 08:01 526465 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21</pre><pre>7f87f83d3000–7f87f85d3000 — -p 00172000 08:01 526465 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21</pre><pre>7f87f85d3000–7f87f85dd000 r — p 00172000 08:01 526465 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21</pre><pre>7f87f85dd000–7f87f85df000 rw-p 0017c000 08:01 526465 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21</pre><pre>7f87f85df000–7f87f85e3000 rw-p 00000000 00:00 0</pre><pre>7f87f85e3000–7f87f8609000 r-xp 00000000 08:01 2888270 /lib/x86_64-linux-gnu/ld-2.23.so</pre><pre>7f87f87ec000–7f87f87f1000 rw-p 00000000 00:00 0</pre><pre>7f87f8806000–7f87f8808000 rw-p 00000000 00:00 0</pre><pre>7f87f8808000–7f87f8809000 r — p 00025000 08:01 2888270 /lib/x86_64-linux-gnu/ld-2.23.so</pre><pre>7f87f8809000–7f87f880a000 rw-p 00026000 08:01 2888270 /lib/x86_64-linux-gnu/ld-2.23.so</pre><pre>7f87f880a000–7f87f880b000 rw-p 00000000 00:00 0</pre><pre>7ffe71238000–7ffe71259000 rw-p 00000000 00:00 0 [stack]</pre><pre>7ffe712c4000–7ffe712c6000 r — p 00000000 00:00 0 [vvar]</pre><pre>7ffe712c6000–7ffe712c8000 r-xp 00000000 00:00 0 [vdso]</pre><pre>ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]</pre><p>Aahh… multitude of hexadecimal numbers. I love it! Welcome to the world of memory addresses! Following table illustrates what each column of our output mean:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s8djrlrHzrz75zdV." /></figure><p>The best resource to learn what each column means and signifies is our very own wise man pages</p><pre>$man proc</pre><p>Here is my attempt to provide brief introductions by taking reference from the man page:</p><p>Address :</p><p>The start address and the end address in the process that the mapping occupies</p><p>Permissions:</p><p>Set of permissions where,</p><pre>r means readable</pre><pre>w means writable</pre><pre>x means executable</pre><pre>p means private i.e it is not shared.</pre><pre>s means shared</pre><p>Offset:</p><p>The offset in the file where the mapping begins. Not every mapping is mapped from a file, so the value of offset is zero in that case.</p><p>Device :</p><p>In the form “major number : minor number” of the associated device, as in, the file from which this mapping is mapped from. Again, the mappings which are not mapped from any file, value is 00:00.</p><p>INode:</p><p>I-node of the related file.</p><p>Pathname:</p><p>The path of the related file. Its blank in case there is no related file.</p><p>In order to identify the segments, we check the access permissions associated with each segment. Let us take the first segment i.e. the first row of the output.</p><pre>00400000–00403000 r-xp 00000000 08:01 262403 /home/parallels/c++/eg4articles/processes/squareSum</pre><p>The access permissions implies it is a readable and executable private segment. From all the segment descriptions, we can make out it is the text segment. The text segment is the read-only with contains the instructions from the binary. Looking at the related file, it is not hard to guess, the region from virtual address 0x00400000 to 0x00403000 is our text segment.</p><p>Moving on to the next row</p><pre>00602000–00603000 r — p 00002000 08:01 262403 /home/parallels/c++/eg4articles/processes/squareSum</pre><p>From the permissions, this looks like a read-only private segment. This is one of the additional read-only segment a process can possess.</p><p>The next one,</p><pre>00603000–00604000 rw-p 00003000 08:01 262403 /home/parallels/c++/eg4articles/processes/squareSum</pre><p>Again, noticing the access permissions, its a read/write segment which points to the data segment of the process.</p><p>The following next row again looks like a segment with read/write permissions.</p><pre>00df2000–00e24000 rw-p 00000000 00:00 0 [heap]</pre><p>It is the heap segment as indicated by the map entry itself. However, notice, it is not related to any file (as offset = major # = minor # = inode = 0).</p><p>The next ones, again reads like text segment, read-only segment and data segment respectively, but the related file is a shared object. As we can see we are linking to: libm (GNU Math), libc, libgc, libstdc++ and ld.</p><pre>7f87f7979000–7f87f7a81000 r-xp 00000000 08:01 2888287 /lib/x86_64-linux-gnu/libm-2.23.so</pre><pre>7f87f7a81000–7f87f7c80000 — -p 00108000 08:01 2888287 /lib/x86_64-linux-gnu/libm-2.23.so</pre><pre>7f87f7c80000–7f87f7c81000 r — p 00107000 08:01 2888287 /lib/x86_64-linux-gnu/libm-2.23.so</pre><pre>7f87f7c81000–7f87f7c82000 rw-p 00108000 08:01 2888287 /lib/x86_64-linux-gnu/libm-2.23.so</pre><pre>7f87f7c82000–7f87f7e41000 r-xp 00000000 08:01 2888281 /lib/x86_64-linux-gnu/libc-2.23.so</pre><pre>7f87f7e41000–7f87f8041000 — -p 001bf000 08:01 2888281 /lib/x86_64-linux-gnu/libc-2.23.so</pre><pre>7f87f8041000–7f87f8045000 r — p 001bf000 08:01 2888281 /lib/x86_64-linux-gnu/libc-2.23.so</pre><pre>7f87f8045000–7f87f8047000 rw-p 001c3000 08:01 2888281 /lib/x86_64-linux-gnu/libc-2.23.so</pre><pre>7f87f8047000–7f87f804b000 rw-p 00000000 00:00 0</pre><p>Note that, although these segments are mapped out of a shared object, though currently in this virtual memory area, they are not shared. Hence the permissions states them as private memory mapping.</p><p>We also see some mappings inside the linked shared objects, where have pathnames as blank. These are anonymous mappings, hence sources are unknown.</p><p>Besides, we have more additional mappings as we can see below:</p><pre>7f87f880a000–7f87f880b000 rw-p 00000000 00:00 0</pre><p>The first one represents yet another anonymous read/write segment which may be used as a backing store.</p><pre>7ffe71238000–7ffe71259000 rw-p 00000000 00:00 0 [stack]</pre><p>The next one with [Stack], is the main thread’s stack segment which enfolds the local variables. The stack mapping can also be listed as [Stack:&lt;threadID&gt;] where it represents the stack for the specified thread ID.</p><pre>7ffe712c4000–7ffe712c6000 r — p 00000000 00:00 0 [vvar]</pre><p>I’ll talk about the [vvar] mapping with [vsyscall] mappings, as they are tied to the same concepts.</p><pre>7ffe712c6000–7ffe712c8000 r-xp 00000000 00:00 0 [vdso]</pre><p>The above one, though not related to any file, but specifies itself by [vdso]. It is a special memory area for kernel provided shared library to aid userspace call to kernel-space. The abbreviated full form is virtual dynamically linked shared object.</p><pre>ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]</pre><pre>7ffe712c4000–7ffe712c6000 r — p 00000000 00:00 0 [vvar]</pre><p>The above two mappings are related to the concepts of how system calls work. As we know, the system calls uses the kernel address space and needs the switch to kernel mode from the user mode. However, these context switching are overheads. To make things work faster, Linux allows to put the read-only system calls into the user process address space, so that they are accessible without the need to switch to the kernel mode. These user-space functions which can access the kernel space informations are called virtual system calls. Hence, we see the mapping for [vsyscall]. As we can see from the permissions in the mapping, it is read only, private and executable segment. To aid virtual system calls, variables from the kernel address space are mapped to the user-space addresses. This mapping is [vvar] as we see here. Its also important to understand here, that now kernel variables will have two address — kernel-space a address and mapped user-space address. Though the later has restricted permissions.</p><p><strong>A simple exercise</strong></p><p>As a very basic experiment, let’s print addresses of the variables we use and match what range and mapping it belongs to.</p><p>I use gdb to take a peek at addresses of the variables, however feel free to add another std::cout in the program, if you like.</p><pre>$ gdb squareSum</pre><pre>(gdb) run</pre><pre>Starting program: /home/parallels/c++/eg4articles/processes/squareSum</pre><pre>Breakpoint 1, main () at squareSum.cpp:21</pre><pre>21 sqSum += (list.at(i)*list.at(i));</pre><pre>(gdb) print&amp;sqSum</pre><pre>$2 = (int64_t *) 0x7fffffffdde8</pre><p>Here is the process memory map of my current squareSum process:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X5mU7rqSWpN9sQx2." /></figure><p>Studying the addresses in the procfs mapping, we see that the local variables belong to the stack segment, as stack memory begins at address 0x7ffffffde000 and end at 0x7ffffffff000. The address of the local variable ‘local_size’ is ‘0x7fffffffdde8’ which is</p><pre>0x7ffffffde000    &gt;   0x7fffffffdde8   &lt;   0x7ffffffff000</pre><pre>|stack-start-addr|     |local_size addr|   |stack-end-addr|</pre><p>Therefore, the mapping we are interested in is,</p><pre>7ffe71238000-7ffe71259000 rw-p 00000000 00:00 0                         [stack]</pre><p>Well, nothing new except the feeling of fulfillment to see our local variable actually sits inside the stack. :)</p><p><strong>One more</strong></p><p>So, now, we know the virtual addresses of the process memory areas and we’ve also experienced the joy to see that the local variables address within the main thread’s stack. Let’s explore more addresses in the space. However, this time I’ll write another program using more of the varied memory areas.</p><p>My next program converts a number to a string.</p><pre>// global variables</pre><pre>uint32_t g_initializedNum = 1210;</pre><pre>uint32_t g_uninitializedNum;</pre><pre>/*convert a number to a string*/</pre><pre>int main()</pre><pre>{</pre><pre>    //local variables</pre><pre>    uint32_t local_size = 1;</pre><pre>    unsigned char *heap_str = NULL; // will find a place in heap</pre><pre>    int32_t local_i = 0;</pre><pre>    uint32_t local_temp = 0;</pre><pre>    /*Determine the length of our output</pre><pre>    string i.e how many numbers form our number*/</pre><pre>    g_uninitializedNum = g_initializedNum;</pre><pre>    while (1)</pre><pre>    {</pre><pre>        g_uninitializedNum /= 10;</pre><pre>        if (!g_uninitializedNum)</pre><pre>        {</pre><pre>            break;</pre><pre>        }</pre><pre>        local_size++;</pre><pre>    }</pre><pre>    printf(“ The computed local size is %d\n”, local_size);</pre><pre>    // Allocate memory for string of</pre><pre>    //computed size + 1 for terminating</pre><pre>    // null character</pre><pre>    heap_str = (unsigned char*) std::malloc ((local_size + 1) * sizeof(unsigned char));</pre><pre>    if (heap_str == NULL)</pre><pre>    {</pre><pre>        printf(“Memory error!\n”);</pre><pre>        exit(1);</pre><pre>    }</pre><pre>    g_uninitializedNum = g_initializedNum;</pre><pre>    for (local_i = local_size — 1;local_i &gt;= 0 ; local_i--)</pre><pre>    {</pre><pre>        local_temp = g_uninitializedNum % 10;</pre><pre>        heap_str[local_i] = local_temp + ‘0’;</pre><pre>        g_uninitializedNum /= 10;</pre><pre>    }</pre><pre>    heap_str[local_size] = 0;</pre><pre>    printf(“The output string is %s \n”, heap_str);</pre><pre>    //We need time to get hold of the memory maps</pre><pre>    sleep(100);</pre><pre>    // Free the heap memory</pre><pre>    std::free(heap_str);</pre><pre>    return 0;</pre><pre>}</pre><p>My intention while writing the above code was to sprinkle the variables in different memory segments, hence pardon the liberty I have taken against writing the most efficient and optimized code. :)</p><p>We are all set for the fun!</p><pre>$ g++ -g -Wall num2string.cpp -o num2string</pre><pre>$ gdb num2string</pre><pre>51 heap_str[local_size] = 0;</pre><pre>(gdb) print &amp;g_initializedNum</pre><pre>$1 = (uint32_t *) 0x601078 &lt;g_initializedNum&gt;</pre><pre>(gdb) print &amp;g_uninitializedNum</pre><pre>$2 = (uint32_t *) 0x601080 &lt;g_uninitializedNum&gt;</pre><pre>(gdb) print &amp;local_size</pre><pre>$3 = (uint32_t *) 0x7fffffffde0c</pre><pre>(gdb) print heap_str</pre><pre>$4 = (unsigned char *) 0x614030 “1210”</pre><p>Let me grab the mappings as well for our currently running num2string process:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W1NWzKdaaGkFgrCF." /></figure><p>We got all the data to analyze.</p><p>Picking up the global variables:</p><pre>$1 = (uint32_t *) 0x601078 &lt;g_initializedNum&gt;</pre><p>Here is the mapping where it belongs:</p><pre>00601000–00602000 rw-p 00001000 08:01 263272 /home/parallels/c++/eg4articles/processes/num2string</pre><p>It is the data segment mapping with read/write permissions.</p><p>With the uninitialized global variables,</p><pre>$2 = (uint32_t *) 0x601080 &lt;g_uninitializedNum&gt;</pre><p>We can see this variable is placed right next to the other global variable in the data segment:</p><pre>00601000–00602000 rw-p 00001000 08:01 263272 /home/parallels/c++/eg4articles/processes/num2string</pre><p>The memory address for the local variables seems to be coming to another mapping.</p><pre>(gdb) print &amp;local_size</pre><pre>$3 = (uint32_t *) 0x7fffffffde0c</pre><p>Going back to our memory map, here is where it belongs:</p><pre>7ffffffde000–7ffffffff000 rw-p 00000000 00:00 0 [stack]</pre><p>Next one is our dynamically allocated memory. Lets see the memory address is in the heap mapping addresses.</p><pre>(gdb) print heap_str</pre><pre>$4 = (unsigned char *) 0x614030 “1210”</pre><p>Here is the mapping the address falls into:</p><pre>00602000–00634000 rw-p 00000000 00:00 0 [heap]</pre><p>Quite obvious and still feels good to see.</p><h4><strong>Creating Processes in programs</strong></h4><p>Standard C facilitates creating processes from a running process. Another interesting and vital fact is that, when a process creates a new process, both the two processes have their own separate memories in the RAM, where each of the process have their own individual process memory segments.</p><p>Let’s look at the two popular ways of creating new processes in a program.</p><p><strong>The system() method</strong></p><p>There is a convenient option to run commandline commands/executables from within a program. It is done through the system() method.</p><p>The syntax from the <a href="http://linux.die.net/man/3/system">man page</a> looks like:</p><pre>int system(const char *command);</pre><p>It takes a command in the format of a string as its input argument and returns the command status after the command completion.</p><p>Here is an example program to illustrate the use of the system() method</p><pre>int main()</pre><pre>{</pre><pre>    int retcode = 0;</pre><pre>    retcode = system(“cat sys.c”);</pre><pre>    return retcode;</pre><pre>}</pre><p>Compiling and running the built binary,</p><pre>$ gcc sys.c -Wall -o sys</pre><pre>$./sys</pre><p>The output I get is:</p><pre>int main()</pre><pre>{</pre><pre>    int retcode = 0;</pre><pre>    retcode = system(“cat sys.c”);</pre><pre>    return retcode;</pre><pre>}</pre><p>Pretty much as we expected. It runs the command given to the system() method which displays the contents of the ‘sys.c’ file on the standard output.</p><p>However, interesting to know is that it isn’t the ‘sys’ process which created the new process running ‘cat’ executable. With the system() method, it creates new process ‘shell’ and hands over the command to it, which in turn triggers the ‘cat’ command and creates that process. To confirm, let us run our squareSum binary from our source and check its parent process.</p><p>Here is the modified source, to trigger squareSum</p><pre>int main()</pre><pre>{</pre><pre>    int retcode = 0;</pre><pre>    retcode = system(“./squareSum”);</pre><pre>    return retcode;</pre><pre>}</pre><p>We build the source and run the binary in the background.</p><pre>$ gcc sys.c -Wall -o sys</pre><pre>$./sys &amp;</pre><p>We know running ‘squareSum’ executable is a blocking call as it has a 100 sec sleep().</p><p>Therefore, in the meanwhile, we wish to see what all processes are running and their PID’s.</p><pre>$ ps</pre><pre>PID TTY TIME CMD</pre><pre>5543 pts/2 00:00:00 bash</pre><pre>14847 pts/2 00:00:00 sys</pre><pre>14848 pts/2 00:00:00 sh</pre><pre>14849 pts/2 00:00:00 squareSum</pre><pre>14883 pts/2 00:00:00 ps</pre><p>We get an inkling from the running ‘sh’ process that it must have been started by the system() call in the ‘sys’ process. Along with, we also notice the ‘squareSum’ process running, which has been launched from within our program using the ‘system()’ call.</p><p>To check the parent process of ‘squareSum’, we use the linux command ‘ps’ as</p><pre>$ ps -f</pre><pre>UID PID PPID C STIME TTY TIME CMD</pre><pre>paralle+ 5543 5536 0 06:02 pts/2 00:00:00 bash</pre><pre>paralle+ 14847 5543 0 14:06 pts/2 00:00:00 ./sys</pre><pre>paralle+ 14848 14847 0 14:06 pts/2 00:00:00 sh -c ./squareSum</pre><pre>paralle+ 14849 14848 0 14:06 pts/2 00:00:00 ./squareSum</pre><pre>paralle+ 14929 5543 0 14:06 pts/2 00:00:00 ps -f</pre><p>Note: One can also use the procfs as /proc/14849/status to know the PPID of the ‘squareSum’ process.</p><p>From the ‘ps -f’ output, we are interested in following processes,</p><pre>paralle+ 14847 5543 0 14:06 pts/2 00:00:00 ./sys</pre><pre>paralle+ 14848 14847 0 14:06 pts/2 00:00:00 sh -c ./squareSum</pre><pre>paralle+ 14849 14848 0 14:06 pts/2 00:00:00 ./squareSum</pre><p>./squareSum sets forth the PPID as ‘14848’ which is the PID of the shell process (i.e. sh -c ./squareSum). Moreover, the PPID of the shell process is ‘14847’ which is the PID of our ‘sys’ process.</p><p><strong>Caveat</strong> Although, using the ‘system()’ method is pretty convenient, it has limitations and drawbacks too. Since, it uses shell to run the command, the behavior of the command will depend upon what shell it is using. If the shell is compromised in security, using the ‘system()’ method could be hazardous.</p><p><strong>The fork() method</strong></p><p>The fork() call is used to create a duplicate child process as the parent process which is calling it. So, from the point, the fork() call was made, both the parent and the child process starts executing the same program instructions following the fork() call.</p><p>The syntax from the <a href="http://linux.die.net/man/2/fork">man page</a> is</p><pre>#include &lt;unistd.h &gt;</pre><pre>pid_t fork(void);</pre><p>Notice we have a data-type provided for the PIDs</p><pre>pid_t</pre><p>Therefore, if we want to store a PID in a variable, we now know what data-type it should be.</p><p>Although we have additional new processes initiating after a fork() is called, there is one distinguishing value to identity the parent vs child process. This distinguishing value is the PID value returned by the fork() call. The parent process will will see the PID returned as the pid of the newly spawned child process. However, in the newly created child process, this PID return value will be zero</p><p>Further, we shall experience using the fork() method in a a very basic program which looks like.</p><pre>int main()</pre><pre>{</pre><pre>    pid_t pid_child = 0;</pre><pre>    int a = 12;</pre><pre>    int b = 3;</pre><pre>    int result = -1;</pre><pre>    printf(“All set to create another process\n”);</pre><pre>    pid_child = fork();</pre><pre>    if (pid_child)</pre><pre>    {</pre><pre>        result = a + b;</pre><pre>        printf(“Root process : The result is %d\n”, result);</pre><pre>    }</pre><pre>    else</pre><pre>    {</pre><pre>        /*The pid_child = 0*/</pre><pre>        result = a * b;</pre><pre>        printf(“Child process : The result is %d\n”, result);</pre><pre>    }</pre><pre>    /*Buying time to check the running processes*/</pre><pre>    sleep(100);</pre><pre>    return 0;</pre><pre>}</pre><p>In the above example source code, we do two different operations in both the child and parent processes. In the parent process, the value returned by fork() would be a valid PID i.e. non-zero positive value. However, in the child process instance, the variable value would be just zero, as this process has just been created.</p><p>Well, are sending both the processes to sleep for 100 seconds.</p><p>Time to compile and launch the process:</p><pre>$ gcc -Wall forkExample.c -o forkExample</pre><pre>$ ./forkExample &amp;</pre><pre>[1] 17338</pre><pre>$ All set to create another process</pre><pre>Root process : The result is 15</pre><pre>Child process : The result is 36</pre><p>The processes are now sleeping after printing the results. Meanwhile, let us check the active process information.</p><pre>$ ps -f</pre><pre>UID PID PPID C STIME TTY TIME CMD</pre><pre>paralle+ 5543 5536 0 06:02 pts/2 00:00:00 bash</pre><pre>paralle+ 17338 5543 0 14:19 pts/2 00:00:00 ./forkExample</pre><pre>paralle+ 17339 17338 0 14:19 pts/2 00:00:00 ./forkExample</pre><pre>paralle+ 17430 5543 0 14:20 pts/2 00:00:00 ps -f</pre><p>From the above output, we identify our two processes with the same command.</p><p>One of them [PID =17338 : CMD = ./forkExample] is our ‘Root’ process which has the PPID [= 5536], same as of the ‘bash’ and second one [ PID = 17339 : CMD = ./forkExample] is the ‘Child’ process which has the PPID [ = 17338] same as as the PID of the first one..</p><p>Thats all for today. Hope you enjoyed fiddling around with the linux processes.</p><blockquote>$ps</blockquote><blockquote>PID CMD</blockquote><blockquote>333 PenProcess</blockquote><blockquote>$kill -9 333</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f56f62b019c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>