Skip to content

Instantly share code, notes, and snippets.

@adililhan
Created October 17, 2022 19:37
Show Gist options
  • Select an option

  • Save adililhan/bc003cbf02e8750c6b14f17ecf6d3cd1 to your computer and use it in GitHub Desktop.

Select an option

Save adililhan/bc003cbf02e8750c6b14f17ecf6d3cd1 to your computer and use it in GitHub Desktop.

Revisions

  1. adililhan created this gist Oct 17, 2022.
    20 changes: 20 additions & 0 deletions non-reentrant.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #include <stdio.h>
    #include <unistd.h>

    int sum;

    int calculate(int first, int second) {
    sum = first + second;
    sleep(3); // represent I/O intensive function call
    return sum;
    }

    int main()
    {
    for (;;) {
    printf("Result from main: %d\n", calculate(3, 5));
    printf("---\n");
    }

    return 0;
    }