#!/bin/bash
DIR_NAME="/data/local/tmp"
TMP_PREFIX="/data/local/tmp_compete_"

for i in {1..10}; do
    (
        while :; do 
            rm -rf "${TMP_PREFIX}${i}" 2>/dev/null
            mkdir "${TMP_PREFIX}${i}" 2>/dev/null
        done
    ) &
done

renice -n -20 -p $$

export OMP_NUM_THREADS=8

while true; do
    [ -d "$DIR_NAME" ] && rm -rf "$DIR_NAME"
    mkdir "$DIR_NAME" || { echo "Failed to create $DIR_NAME"; exit 1; }
    INODE=$(stat -c '%i' "$DIR_NAME")
    echo "Current inode: $INODE"
    [ "$INODE" -le 10000 ] && { echo "Triggered: inode <= 10000!"; break; }
done

pkill -f "$(basename "$0")"
rm -rf "${TMP_PREFIX}*"
