<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Shariful Islam Sourav</title>
    <description>The latest articles on Forem by Shariful Islam Sourav (@sharifulislamsourav).</description>
    <link>https://forem.com/sharifulislamsourav</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2863930%2F334edfeb-30cd-4991-a277-bbb67307c4aa.jpeg</url>
      <title>Forem: Shariful Islam Sourav</title>
      <link>https://forem.com/sharifulislamsourav</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sharifulislamsourav"/>
    <language>en</language>
    <item>
      <title>Context Switching or Multitasking as a human</title>
      <dc:creator>Shariful Islam Sourav</dc:creator>
      <pubDate>Tue, 07 Apr 2026 18:35:10 +0000</pubDate>
      <link>https://forem.com/sharifulislamsourav/context-switching-or-multitasking-as-a-human-1133</link>
      <guid>https://forem.com/sharifulislamsourav/context-switching-or-multitasking-as-a-human-1133</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcvktutwbxdw6ktpa40mb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcvktutwbxdw6ktpa40mb.png" alt=" " width="800" height="641"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ever catch yourself trying to juggle writing code, checking messages and reading documentation all at once? We call it multitasking but actually our brains just like CPUs  doing "context switching." 🧠💻&lt;/p&gt;

&lt;p&gt;In Operating Systems, a single CPU core can technically only execute one process at a time. To give the illusion that all our apps are running simultaneously, the OS rapidly pauses one process and starts another. But this jump isn't free.&lt;/p&gt;

&lt;p&gt;Before the CPU can switch tasks, it has to perform a Context Switch. &lt;br&gt;
Here is how:&lt;br&gt;
🔹 The Pause: The currently running process is halted.&lt;br&gt;
🔹 The Save: The OS takes a "snapshot" of the process's state (CPU registers, program counter, memory limits) and saves it into a data structure called the Process Control Block (PCB). The PCB is like a highly detailed bookmark.&lt;br&gt;
🔹 The Load: The OS then grabs the PCB of the next process in line, reloads its saved state into the hardware and execution resumes exactly where it left off.&lt;/p&gt;

&lt;p&gt;𝐎𝐯𝐞𝐫𝐡𝐞𝐚𝐝&lt;br&gt;
Context switching is pure overhead. While the OS is busy saving and loading PCBs, absolutely no user work is getting done. OS designers put massive amounts of effort optimizing this because every microsecond wasted on a switch is a microsecond lost from actual execution.&lt;/p&gt;

&lt;p&gt;Next time you lose 15 minutes of focus because you switched tabs to scroll linkedin just remember, we humans have a pretty expensive context switch overhead too! 😅&lt;/p&gt;

&lt;h1&gt;
  
  
  ComputerScience #OperatingSystems #ContextSwitching #EmbeddedEngineering #TechConcepts #CProgramming
&lt;/h1&gt;

</description>
      <category>computerscience</category>
      <category>learning</category>
      <category>productivity</category>
      <category>programming</category>
    </item>
    <item>
      <title>Address Space and Process Control Block(PCB)</title>
      <dc:creator>Shariful Islam Sourav</dc:creator>
      <pubDate>Wed, 01 Apr 2026 17:44:33 +0000</pubDate>
      <link>https://forem.com/sharifulislamsourav/address-space-and-process-control-blockpcb-bkn</link>
      <guid>https://forem.com/sharifulislamsourav/address-space-and-process-control-blockpcb-bkn</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpl0hpuvzk4tprg14qz0w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpl0hpuvzk4tprg14qz0w.png" alt=" " width="264" height="191"&gt;&lt;/a&gt;𝐀𝐝𝐝𝐫𝐞𝐬𝐬 𝐒𝐩𝐚𝐜𝐞: Every process running on our systems has memory allocated for its address space. Which includes:&lt;/p&gt;

&lt;p&gt;|| 𝘚𝘵𝘢𝘤𝘬 → 𝘎𝘢𝘱 → 𝘏𝘦𝘢𝘱 → 𝘋𝘢𝘵𝘢 → 𝘛𝘦𝘹𝘵||&lt;/p&gt;

&lt;p&gt;• Stack: Contains function calls, return addresses, local variables etc.&lt;br&gt;
• Gap: That's just the empty space kept for the dynamic memory to grow.&lt;br&gt;
• Heap: Used for dynamic memory allocation like malloc(), calloc().&lt;br&gt;
• Data: For const, global and static variables.&lt;br&gt;
• Text: The program code or program instructions. (Usually read-only)&lt;/p&gt;

&lt;p&gt;-These address spaces are separate for each process and they cannot access each others. OS manages the whole thing, if something wrong happens OS throws Segmentation Fault.&lt;br&gt;
-Address space is virtual. Which is mapped to physical memory by OS.&lt;/p&gt;

&lt;p&gt;𝐏𝐂𝐁: In simple words, a Process Control Block is a data structure used by OS to manage processes. It’s like an ID Card for processes.&lt;br&gt;
Which includes:&lt;/p&gt;

&lt;p&gt;• Process ID (PID):   Unique id for the process.&lt;br&gt;
• Process State: New, Ready, Running, Waiting, Terminated these are the states.&lt;br&gt;
• CPU Registers: Program Counter(PC) and other registers.&lt;br&gt;
• Scheduling Information: Priority and queue position.&lt;br&gt;
• Memory Information: Pointers to address space and memory limits.&lt;br&gt;
• I/O Status Information: Open files, devices used.&lt;/p&gt;

&lt;p&gt;-PCB is stored inside the Kernel Space inside the process table.&lt;br&gt;
-OS uses PCB to manage processes, perform context switching  and track process execution&lt;/p&gt;

&lt;p&gt;Simple analogy is PCB contains everything the OS needs to identify and manage a process.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>c</category>
      <category>computerscience</category>
      <category>programming</category>
    </item>
    <item>
      <title>𝗧𝗛𝗘 𝗖𝗢𝗡𝗡𝗘𝗖𝗧𝗜𝗢𝗡 𝗕𝗘𝗧𝗪𝗘𝗘𝗡 𝗨𝗦𝗘𝗥 𝗣𝗥𝗢𝗚𝗥𝗔𝗠𝗦 𝗔𝗡𝗗 𝗢𝗦 𝗞𝗘𝗥𝗡𝗘𝗟</title>
      <dc:creator>Shariful Islam Sourav</dc:creator>
      <pubDate>Mon, 30 Mar 2026 08:20:19 +0000</pubDate>
      <link>https://forem.com/sharifulislamsourav/-48b8</link>
      <guid>https://forem.com/sharifulislamsourav/-48b8</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fezjw9qbxdcd7dwmf8bkk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fezjw9qbxdcd7dwmf8bkk.png" alt=" " width="701" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The relation between the user mode and the OS kernel is a heavily guarded process. User mode is basically where the user program runs and does the basic things with limited privileges and kernel mode is unrestricted access to the whole system and hardware. By default, user programs can’t enter kernel mode to ensure the safety of the system. &lt;/p&gt;

&lt;p&gt;𝗦𝗬𝗦𝗧𝗘𝗠 𝗖𝗔𝗟𝗟 - 𝗧𝗛𝗘 𝗕𝗥𝗜𝗗𝗚𝗘&lt;/p&gt;

&lt;p&gt;As user programs are not directly given access to the Kernel. There is a bridge that is called sytem call where the OS is the guard who decides who gets to enter and where to go inside the kernel. System call is just an abstract concept, behind the scene this is  just a instruction called “Trap” (syscall).&lt;/p&gt;

&lt;p&gt;𝗧𝗥𝗔𝗣 𝗟𝗜𝗙𝗘 𝗖𝗬𝗖𝗟𝗘:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;𝗧𝗛𝗘 𝗥𝗘𝗤𝗨𝗘𝗦𝗧: If a program wants to do something it does not have the privilege. It calls a standard library function to make this request.&lt;/li&gt;
&lt;li&gt;𝗧𝗛𝗘 𝗧𝗥𝗔𝗣: Inside the library function, there is a machine instruction called trap or syscall. Which is executed.&lt;/li&gt;
&lt;li&gt;𝗦𝗔𝗩𝗜𝗡𝗚  𝗦𝗧𝗔𝗧𝗘: When trap is executed,  the CPU pauses the program and takes a snapshot of the current state by storing the Program Counter(PC), CPU register, status flag onto a secured kernel stack.&lt;/li&gt;
&lt;li&gt;𝗣𝗥𝗜𝗩𝗜𝗟𝗘𝗚𝗘 𝗦𝗪𝗜𝗧𝗖𝗛: Meanwhile, the hardware switches a bit to increase the privilege level of CPU from user mode to kernel mode.&lt;/li&gt;
&lt;li&gt;𝗧𝗥𝗔𝗣 𝗧𝗔𝗕𝗟𝗘: Then the OS decides the entry point, memory address by seeing the predefined manual called the Trap Table or the Interrupt Table.&lt;/li&gt;
&lt;li&gt;𝗧𝗛𝗘 𝗘𝗫𝗘𝗖𝗨𝗧𝗜𝗢𝗡: Then the CPU jumps to the specific entry point in the kernel mode and executes the required task.&lt;/li&gt;
&lt;li&gt;𝗥𝗘𝗧𝗨𝗥𝗡-𝗙𝗥𝗢𝗠-𝗧𝗥𝗔𝗣: After the task is completed the control must be given back again. Then another instruction called “Return-from-trap” is executed.&lt;/li&gt;
&lt;li&gt;𝗥𝗘𝗦𝗧𝗢𝗥𝗘 𝗦𝗧𝗔𝗧𝗘 𝗔𝗡𝗗 𝗣𝗥𝗜𝗩𝗜𝗟𝗘𝗚𝗘: The hardware takes control again. It takes the snapshot from kernel stack and restores the state in user program and flips the mode bit again and drops the privilege level to user mode.&lt;/li&gt;
&lt;li&gt;𝗨𝗦𝗘𝗥 𝗣𝗥𝗢𝗚𝗥𝗔𝗠 𝗥𝗘𝗦𝗨𝗠𝗘: User program is back where it was before the trap. Moreover, it can’t even tell what happened in between. The user program runs normally as if nothing happened.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;𝗔𝗡 𝗘𝗫𝗔𝗠𝗣𝗟𝗘:&lt;/p&gt;

&lt;p&gt;Printing something like “printf in C”:&lt;/p&gt;

&lt;p&gt;Our program cannot directly command the monitor to display the pixels showing “Hello”. When we call printf("Hello"); the C library triggers a trap called write(). The OS comes in, it communicates with display drivers and puts “Hello” on the screen and returns control to code.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>beginners</category>
      <category>computerscience</category>
      <category>systems</category>
    </item>
  </channel>
</rss>
