<?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>DEV Community: Tabrez Ahmed</title>
    <description>The latest articles on DEV Community by Tabrez Ahmed (@seucra).</description>
    <link>https://dev.to/seucra</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%2F3844957%2F9a0d7eb3-d14b-42a1-8a09-2a818c591780.jpg</url>
      <title>DEV Community: Tabrez Ahmed</title>
      <link>https://dev.to/seucra</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/seucra"/>
    <language>en</language>
    <item>
      <title>Concurrency in Python: Solving the Dining Philosophers Problem</title>
      <dc:creator>Tabrez Ahmed</dc:creator>
      <pubDate>Sun, 19 Apr 2026 17:26:11 +0000</pubDate>
      <link>https://dev.to/seucra/concurrency-in-python-solving-the-dining-philosophers-problem-6ao</link>
      <guid>https://dev.to/seucra/concurrency-in-python-solving-the-dining-philosophers-problem-6ao</guid>
      <description>&lt;p&gt;If you are writing multithreaded applications, you are going to run into deadlocks. There’s no avoiding it. To understand how to fix them, you need to understand the Dining Philosophers problem.&lt;/p&gt;

&lt;p&gt;Five philosophers sit at a round table. There are five forks. To eat, a philosopher needs the fork on their left and the fork on their right. If everyone grabs their left fork at the exact same time, they all wait forever for the right fork. Deadlock.&lt;/p&gt;

&lt;p&gt;In this series, my team and I will break down how we built a visual simulator for this problem in Python. For part one, we are looking at the core mechanics and Dijkstra’s Resource Hierarchy solution.&lt;br&gt;
The Setup&lt;/p&gt;

&lt;p&gt;We want raw execution without third-party bloat, so we rely entirely on Python's standard threading library. Each philosopher is a daemon thread, and each fork is a threading.Lock.&lt;br&gt;
Python&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;threading&lt;/span&gt;

&lt;span class="n"&gt;NUM_PHILOSOPHERS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="n"&gt;forks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;threading&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Lock&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;NUM_PHILOSOPHERS&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we just wrote forks[left].acquire() followed by forks[right].acquire(), the script would eventually freeze.&lt;br&gt;
The Solution: Resource Hierarchy&lt;/p&gt;

&lt;p&gt;To break the circular wait, we assign a hierarchy to the resources (forks). Instead of "grab left, then right," the rule becomes "grab the lower-numbered fork first, then the higher-numbered one."&lt;/p&gt;

&lt;p&gt;Here is how that logic looks in our simulation loop:&lt;br&gt;
Python&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_cycle_resource_hierarchy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;idx&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# Determine fork indices
&lt;/span&gt;    &lt;span class="n"&gt;left&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;idx&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;NUM_PHILOSOPHERS&lt;/span&gt;
    &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;idx&lt;/span&gt;

    &lt;span class="c1"&gt;# Establish hierarchy
&lt;/span&gt;    &lt;span class="n"&gt;lo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Acquire in strict order
&lt;/span&gt;    &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;forks&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;lo&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;acquire&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;forks&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;acquire&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# CRITICAL SECTION: Eating
&lt;/span&gt;    &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;uniform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="c1"&gt;# Release locks
&lt;/span&gt;    &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;forks&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;release&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;forks&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;lo&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;release&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because the last philosopher (index 4) sits next to the first fork (index 0), they will try to grab fork 0 first, while philosopher 0 is also trying to grab fork 0 first. The cycle is broken. Someone gets blocked, allowing someone else to eat.&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>computerscience</category>
      <category>python</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>My First Week Learning Offensive Security (Before Hitting the Paywall)</title>
      <dc:creator>Tabrez Ahmed</dc:creator>
      <pubDate>Sun, 05 Apr 2026 12:06:17 +0000</pubDate>
      <link>https://dev.to/seucra/my-first-week-learning-offensive-security-before-hitting-the-paywall-3g55</link>
      <guid>https://dev.to/seucra/my-first-week-learning-offensive-security-before-hitting-the-paywall-3g55</guid>
      <description>&lt;p&gt;I started learning red team fundamentals on TryHackMe. Here's what I learned before running into premium content limitations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Day 1: Red Team Basics
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;What offensive security actually means&lt;/li&gt;
&lt;li&gt;Learned about dirb tool for directory brute-forcing&lt;/li&gt;
&lt;li&gt;[Explain what dirb does and why it's useful]&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Day 2: Blue Team Perspective
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Defense in depth concept&lt;/li&gt;
&lt;li&gt;SOC analyst role&lt;/li&gt;
&lt;li&gt;What SIEM tools do&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Day 3: Research Skills
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;How to find CVEs and exploits&lt;/li&gt;
&lt;li&gt;Tools: Shodan, Censys, VirusTotal&lt;/li&gt;
&lt;li&gt;GitHub for exploit code&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Day 4: Linux Fundamentals
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Commands I learned: ls, cd, cat, grep&lt;/li&gt;
&lt;li&gt;Operators: &amp;amp;&amp;amp;, &amp;gt;, |&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Paywall Problem
&lt;/h2&gt;

&lt;p&gt;TryHackMe's free tier is limited. Switching to OverTheWire (completely free) to continue learning.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next Week
&lt;/h2&gt;

&lt;p&gt;Starting OverTheWire Bandit challenges. Goal: Complete levels 0-10.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
