bounded \u0935\u0947\u091f\u093f\u0902\u0917<\/li>\n<\/ol>\n\u0907\u0928 \u0938\u092d\u0940 \u092b\u0948\u0915\u094d\u091f\u0930 \u0915\u094b \u0938\u0941\u0928\u093f\u0936\u094d\u091a\u093f\u0924 \u0915\u0930\u0928\u0947 \u0915\u093e \u090f\u0915 \u0924\u0930\u0940\u0915\u093e \u092a\u0940\u091f\u0930\u0938\u0928 \u0905\u0932\u094d\u0917\u094b\u0930\u093f\u0925\u092e \u092d\u0940 \u0939\u0948\u0964<\/p>\n
\u0907\u0938\u0940 \u0915\u0947 \u0932\u093f\u090f Dekker\u2019s <\/b>\u0938\u0932\u0942\u0936\u0928 \u092d\u0940 \u0906\u0924\u093e \u0939\u0948\u0964 \u0907\u0938\u0947 \u0915\u094d\u0930\u093f\u091f\u093f\u0915\u0932 \u0938\u0947\u0915\u094d\u0936\u0928 \u092a\u094d\u0930\u0949\u092c\u094d\u0932\u092e \u0915\u093e \u092a\u0939\u0932\u093e \u0938\u0939\u0940 \u0938\u0932\u0942\u0936\u0928 \u092d\u0940 \u092e\u093e\u0928\u093e \u091c\u093e\u0924\u093e \u0939\u0948\u0964 \u092f\u0947 \u0926\u094b \u0925\u094d\u0930\u0947\u0921 \u0915\u094b \u090f\u0915 \u0938\u093f\u0902\u0917\u0932 \u092f\u0942\u091c \u0930\u093f\u0938\u094b\u0930\u094d\u0938 \u0915\u094b \u0936\u0947\u092f\u0930 \u0915\u0930\u0928\u0947 \u0915\u0940 \u0905\u0928\u0941\u092e\u0924\u093f \u0926\u0947\u0924\u093e \u0939\u0948 \u0914\u0930 \u0935\u094b \u092d\u0940 \u092c\u093f\u0928\u093e \u0915\u093f\u0938\u0940 \u091f\u0915\u0930\u093e\u0935 \u0915\u0947\u0964<\/p>\n
\u0907\u0938\u092e\u0947\u0902 \u0915\u092e\u094d\u092f\u0941\u0928\u093f\u0915\u0947\u0936\u0928 \u0915\u0947 \u0932\u093f\u090f \u0915\u0947\u0935\u0932 \u0936\u0947\u092f\u0930\u094d\u0921 \u092e\u0947\u092e\u094b\u0930\u0940 \u0915\u093e \u0939\u0940 \u092a\u094d\u0930\u092f\u094b\u0917 \u0915\u093f\u092f\u093e \u091c\u093e\u0924\u093e \u0939\u0948\u0964 \u092f\u0947 \u0915\u0920\u093f\u0928 \u0914\u0930 \u0915\u093e\u092e\u094d\u092a\u094d\u0932\u0947\u0915\u094d\u0938 \u0905\u0932\u094d\u0917\u094b\u0930\u093f\u0925\u092e \u0915\u0940 \u0915\u0920\u093f\u0928\u093e\u0907\u092f\u094b\u0902 \u0938\u0947 \u0928\u093f\u0915\u0932 \u0906\u0924\u093e \u0939\u0948\u0964 \u092f\u0947 \u092e\u094d\u092f\u0942\u091a\u094d\u092f\u0942\u0905\u0932 \u090f\u0915\u094d\u0938\u0915\u094d\u0932\u0942\u0936\u0928 \u0915\u094b implement \u0915\u0930\u0928\u0947 \u0935\u093e\u0932\u0947 \u092a\u0939\u0932\u0947 \u0905\u0932\u094d\u0917\u094b\u0930\u093f\u0925\u092e \u092e\u0947\u0902 \u0938\u0947 \u090f\u0915 \u0939\u0948\u0964
\n<\/b><\/p>\n
\u092f\u0926\u094d\u0926\u092a\u093f \u0907\u0938 \u0905\u0932\u094d\u0917\u094b\u0930\u093f\u0925\u092e \u0915\u0947 \u092c\u0939\u0941\u0924 \u0938\u093e\u0930\u0947 \u0935\u0930\u094d\u091c\u0928 \u0939\u0948\u0902 \u0932\u0947\u0915\u093f\u0928 \u0905\u0902\u0924\u093f\u092e \u092a\u093e\u0902\u091a\u0935\u0947 \u0905\u0930\u094d\u091c\u0928 \u0915\u094b \u0939\u0940 \u0910\u0938\u093e \u092e\u0928 \u0917\u092f\u093e \u0939\u0948 \u091c\u094b \u0938\u092d\u0940 \u0909\u092a\u0930 \u0932\u093f\u0916\u0947 \u0936\u0930\u094d\u0924\u094b\u0902 \u0915\u094b \u0938\u0902\u0924\u0941\u0937\u094d\u091f \u0915\u0930\u0924\u093e \u0939\u0948 \u0914\u0930 \u0907\u0928 \u0938\u092c\u092e\u0947 \u0938\u092c\u0938\u0947 \u091c\u094d\u092f\u093e\u0926\u093e efficient \u092d\u0940 \u0939\u0948\u0964<\/p>\n
\u0928\u094b\u091f\u2013<\/b> Dekker’s \u0905\u0932\u094d\u0917\u094b\u0930\u093f\u0925\u092e \u0938\u0932\u0942\u0936\u0928 \u091c\u094b \u092f\u0939\u093e\u0901 \u092c\u0924\u093e\u092f\u093e \u0917\u092f\u093e \u0939\u0948 \u0935\u094b \u0915\u0947\u0935\u0932 \u0926\u094b \u092a\u094d\u0930\u094b\u0938\u0947\u0938 \u0915\u0947 \u092c\u0940\u091a \u0939\u0940 \u092e\u094d\u092f\u0942\u091a\u094d\u092f\u0942\u0905\u0932 \u090f\u0915\u094d\u0938\u0915\u094d\u0932\u0942\u0936\u0928 \u0915\u094b \u0938\u0941\u0928\u093f\u0936\u094d\u091a\u093f\u0924 \u0915\u0930\u0924\u093e \u0939\u0948\u0964 \u0907\u0938\u0947 \u0910\u0930\u0947 \u0914\u0930 \u0935\u0947\u0930\u093f\u090f\u092c\u0932 \u0915\u093e \u0938\u0939\u0940 \u092a\u094d\u0930\u092f\u094b\u0917 \u0915\u0930 \u0915\u0947 \u0926\u094b \u092a\u094d\u0930\u094b\u0938\u0947\u0938 \u0938\u0947 \u091c\u094d\u092f\u093e\u0926\u093e \u092a\u0930 \u092d\u0940 \u0932\u0917\u093e\u092f\u093e \u091c\u093e \u0938\u0915\u0924\u093e \u0939\u0948\u0964<\/p>\n
\u0905\u0932\u094d\u0917\u094b\u0930\u093f\u0925\u092e\u2013<\/b> \u0907\u0938\u0947 \u0926\u094b\u0928\u094b\u0902 \u091a\u0940\u091c\u0947\u0902 \u091a\u093e\u0939\u093f\u090f \u0939\u094b\u0924\u0940 \u0939\u0948- \u092c\u0942\u0932\u093f\u092f\u0928 \u092e\u093e\u0928 \u0915\u093e \u0910\u0930\u0947 \u0914\u0930 \u0907\u0928\u094d\u091f\u093f\u091c\u0930 \u0935\u0947\u0930\u093f\u090f\u092c\u0932\u0964<\/p>\nvar flag: array [0..1] of boolean;\r\nturn: 0..1;\r\nrepeat\r\n\r\n flag[i] := true;\r\n while flag[j] do\r\n if turn = j then\r\n begin\r\n flag[i] := false;\r\n while turn = j do no-op;\r\n flag[i] := true;\r\n end;\r\n\r\n critical section\r\n\r\n turn := j;\r\n flag[i] := false;\r\n\r\n remainder section\r\n\r\nuntil false;<\/pre>\n\u0921\u0947\u0915\u0930 \u090f\u0932\u094d\u0917\u094b\u0930\u093f\u0925\u092e \u0915\u093e \u092a\u0939\u0932\u093e \u0935\u0930\u094d\u091c\u0928<\/h3>\n
\u0907\u0938\u092e\u0947\u0902 \u092a\u094d\u0930\u094b\u0938\u0947\u0938 \u0915\u0947 \u092c\u0940\u091a \u0915\u0949\u092e\u0928 \u092f\u093e \u0936\u0947\u092f\u0930\u094d\u0921 \u0925\u094d\u0930\u0947\u0921 \u0938\u0902\u0916\u094d\u092f\u093e \u0915\u093e \u092a\u094d\u0930\u092f\u094b\u0917 \u0915\u093f\u092f\u093e \u091c\u093e\u0924\u093e \u0939\u0948\u0964 \u0907\u0938\u092e\u0947\u0902 \u0905\u0917\u0930 \u0936\u0947\u092f\u0930\u094d\u0921 \u0925\u094d\u0930\u0947\u0921 \u092f\u0947 \u092c\u0924\u093e\u0924\u093e \u0939\u0948 \u0915\u093f \u092a\u0939\u0932\u0947 \u0938\u0947 \u0939\u0940 \u0905\u0917\u0930 \u0915\u094b\u0908 \u092a\u094d\u0930\u094b\u0938\u0947\u0938 \u091a\u0932 \u0930\u0939\u093e \u0939\u0948 \u0924\u094b \u092c\u093e\u0902\u0915\u0940 \u092a\u094d\u0930\u094b\u0938\u0947\u0938 \u0915\u094b \u0915\u094d\u0930\u093f\u091f\u093f\u0915\u0932 \u0938\u0947\u0915\u094d\u0936\u0928 \u092e\u0947\u0902 \u090f\u0902\u091f\u094d\u0930\u0940 \u0932\u0947\u0928\u0947 \u0938\u0947 \u0930\u094b\u0915 \u0926\u093f\u092f\u093e \u091c\u093e\u0924\u093e \u0939\u0948\u0964<\/p>\n
\n
Main()<\/code><\/div>\n{<\/code><\/div>\n<\/div>\n
int<\/code> thread_number = 1;<\/code><\/div>\nstartThreads();<\/code><\/div>\n}<\/code><\/div>\n<\/div>\n
Thread1()<\/code><\/div>\n{<\/code><\/div>\ndo<\/code> {<\/code><\/div>\n<\/div>\n
\/\/ entry section<\/code><\/div>\n\/\/ wait until threadnumber is 1<\/code><\/div>\nwhile<\/code> (threadnumber == 2)<\/code><\/div>\n;<\/code><\/div>\n<\/div>\n
\/\/ critical section<\/code><\/div>\n<\/div>\n
\/\/ exit section<\/code><\/div>\n\/\/ give access to the other thread<\/code><\/div>\nthreadnumber = 2;<\/code><\/div>\n<\/div>\n
\/\/ remainder section<\/code><\/div>\n<\/div>\n
} <\/code>while<\/code> (completed == <\/code>false<\/code>)<\/code><\/div>\n}<\/code><\/div>\n<\/div>\n
Thread2()<\/code><\/div>\n{<\/code><\/div>\n<\/div>\n
do<\/code> {<\/code><\/div>\n<\/div>\n
\/\/ entry section<\/code><\/div>\n\/\/ wait until threadnumber is 2<\/code><\/div>\nwhile<\/code> (threadnumber == 1)<\/code><\/div>\n;<\/code><\/div>\n<\/div>\n
\/\/ critical section<\/code><\/div>\n<\/div>\n
\/\/ exit section<\/code><\/div>\n\/\/ give access to the other thread<\/code><\/div>\nthreadnumber = 1;<\/code><\/div>\n<\/div>\n
\/\/ remainder section<\/code><\/div>\n<\/div>\n
} <\/code>while<\/code> (completed == <\/code>false<\/code>)<\/code><\/div>\n}<\/code><\/div>\n<\/div>\n<\/div>\n
\u0909\u092a\u0930 \u0935\u093e\u0932\u0947 \u0907\u092e\u094d\u092a\u094d\u0932\u0940\u092e\u0947\u0902\u091f\u0947\u0936\u0928 \u092e\u0947\u0902 \u092f\u0947 \u0938\u092e\u0938\u094d\u092f\u093e \u0906\u0924\u0940 \u0939\u0948 \u0915\u093f \u092f\u0947 \u0932\u0949\u0915\u0938\u094d\u091f\u0947\u092a \u0938\u093f\u0902\u0915\u094d\u0930\u094b\u0928\u093e\u0907\u091c\u0947\u0936\u0928 \u0939\u0948 \u092f\u093e\u0928\u0940 \u0915\u093f \u0907\u0938\u092e\u0947\u0902 \u0939\u0930 \u090f\u0915 \u0925\u094d\u0930\u0947\u0921 execution \u0915\u0947 \u0932\u093f\u090f \u0926\u0942\u0938\u0930\u0947 \u092a\u0930 \u0928\u093f\u0930\u094d\u092d\u0930 \u0939\u094b\u0924\u093e \u0939\u0948\u0964 \u0905\u0917\u0930 \u0909\u0928\u092e\u0947 \u0938\u0947 \u0915\u094b\u0908 \u090f\u0915 \u092a\u094d\u0930\u094b\u0938\u0947\u0938 \u092a\u0942\u0930\u093e \u0939\u094b \u091c\u093e\u0924\u093e \u0939\u0948 \u0924\u094b \u0926\u0942\u0938\u0930\u093e \u092a\u094d\u0930\u094b\u0938\u0947\u0938 \u0930\u0928 \u0939\u094b\u0924\u093e \u0939\u0948 \u0914\u0930 \u090f\u0915 \u0915\u094b \u092a\u0942\u0930\u093e \u090f\u0915\u094d\u0938\u0947\u0938 \u0926\u0947 \u0926\u0947\u0924\u093e \u0939\u0948 \u0914\u0930 \u0905\u092a\u0928\u0940 \u092c\u093e\u0930\u0940 \u0915\u093e \u0907\u0928\u094d\u0924\u091c\u093e\u0930 \u0915\u0930\u0924\u093e \u0939\u0948\u0964 \u091c\u092c\u0915\u093f \u092a\u0939\u0932\u093e \u092a\u094d\u0930\u094b\u0938\u0947\u0938 \u092a\u0939\u0932\u0947 \u0939\u0940 \u092a\u0942\u0930\u093e \u0939\u094b \u091c\u093e\u0924\u093e \u0939\u0948 \u0914\u0930 \u0914\u0930 \u090f\u0915\u094d\u0938\u0947\u0938 \u0915\u094b \u0926\u0942\u0938\u0930\u0947 \u0935\u093e\u0932\u0947 \u0915\u094b \u0915\u092d\u0940 \u0935\u093e\u092a\u0938 \u0928\u0939\u0940\u0902 \u0915\u0930\u0924\u093e\u0964 \u0907\u0938\u0940\u0932\u093f\u090f \u0926\u0942\u0938\u0930\u093e \u092a\u094d\u0930\u094b\u0938\u0947\u0938 \u0939\u092e\u0947\u0936\u093e \u0915\u0947 \u0932\u093f\u090f \u0907\u0928\u094d\u0924\u091c\u093e\u0930 \u0939\u0940 \u0915\u0930\u0924\u093e \u0930\u0939 \u091c\u093e\u0924\u093e \u0939\u0948\u0964<\/div>\n
\u0921\u0947\u0915\u0930 \u090f\u0932\u094d\u0917\u094b\u0930\u093f\u0925\u092e \u0915\u093e \u0926\u0942\u0938\u0930\u093e \u0935\u0930\u094d\u091c\u0928<\/h3>\n
\u0932\u0949\u0915\u0938\u094d\u091f\u0947\u092a \u0938\u093f\u0902\u0915\u094d\u0930\u094b\u0928\u093e\u0907\u091c\u0947\u0936\u0928 \u0915\u094b \u0939\u091f\u093e\u0928\u0947 \u0915\u0947 \u0932\u093f\u090f \u092f\u0947 \u0926\u094b \u092b\u094d\u0932\u0948\u0917 \u0915\u093e \u092a\u094d\u0930\u092f\u094b\u0917 \u0915\u0930\u0924\u093e \u0939\u0948 \u091c\u094b \u0907\u0938\u0915\u093e \u0905\u092d\u0940 \u0915\u093e \u0938\u094d\u091f\u0947\u091f\u0938 \u0926\u093f\u0916\u093e\u0924\u093e \u0939\u0948 \u0914\u0930 \u090f\u0902\u091f\u094d\u0930\u0940 \u0914\u0930 \u090f\u0917\u094d\u091c\u093f\u091f \u0935\u093e\u0932\u0947 \u0938\u0947\u0915\u094d\u0936\u0928 \u092a\u0930 \u0909\u0928\u094d\u0939\u0947\u0902 \u0905\u092a\u0921\u0947\u091f \u0915\u0930\u0924\u093e \u0939\u0948\u0964<\/p>\n
\n
Main()<\/code><\/div>\n{<\/code><\/div>\n<\/div>\n
\/\/ flags to indicate if each thread is in<\/code><\/div>\n\/\/ its critial section or not.<\/code><\/div>\nboolean thread1 = <\/code>false<\/code>;<\/code><\/div>\nboolean thread2 = <\/code>false<\/code>;<\/code><\/div>\n<\/div>\n
startThreads();<\/code><\/div>\n}<\/code><\/div>\n<\/div>\n
Thread1()<\/code><\/div>\n{<\/code><\/div>\n<\/div>\n
do<\/code> {<\/code><\/div>\n<\/div>\n
\/\/ entry section<\/code><\/div>\n\/\/ wait until thread2 is in its critical section<\/code><\/div>\nwhile<\/code> (thread2 == <\/code>true<\/code>)<\/code><\/div>\n;<\/code><\/div>\n<\/div>\n
\/\/ indicate thread1 entering its critical section<\/code><\/div>\nthread1 = <\/code>true<\/code>;<\/code><\/div>\n<\/div>\n
\/\/ critical section<\/code><\/div>\n<\/div>\n
\/\/ exit section<\/code><\/div>\n\/\/ indicate thread1 exiting its critical section<\/code><\/div>\nthread1 = <\/code>false<\/code>;<\/code><\/div>\n<\/div>\n
\/\/ remainder section<\/code><\/div>\n<\/div>\n
} <\/code>while<\/code> (completed == <\/code>false<\/code>)<\/code><\/div>\n}<\/code><\/div>\n<\/div>\n
Thread2()<\/code><\/div>\n{<\/code><\/div>\n<\/div>\n
do<\/code> {<\/code><\/div>\n<\/div>\n
\/\/ entry section<\/code><\/div>\n\/\/ wait until thread1 is in its critical section<\/code><\/div>\nwhile<\/code> (thread1 == <\/code>true<\/code>)<\/code><\/div>\n;<\/code><\/div>\n<\/div>\n
\/\/ indicate thread2 entering its critical section<\/code><\/div>\nthread2 = <\/code>true<\/code>;<\/code><\/div>\n<\/div>\n
\/\/ critical section<\/code><\/div>\n<\/div>\n
\/\/ exit section<\/code><\/div>\n\/\/ indicate thread2 exiting its critical section<\/code><\/div>\nthread2 = <\/code>false<\/code>;<\/code><\/div>\n<\/div>\n
\/\/ remainder section<\/code><\/div>\n<\/div>\n
} <\/code>while<\/code> (completed == <\/code>false<\/code>)<\/code><\/div>\n}<\/code><\/div>\n<\/div>\n<\/div>\n
\u0907\u0938 \u0935\u093e\u0932\u0947 \u0935\u0930\u094d\u091c\u0928 \u092e\u0947\u0902 \u092f\u0947 \u0938\u092e\u0938\u094d\u092f\u093e \u0906\u0924\u0940 \u0939\u0948 \u0915\u093f \u0907\u0938\u092e\u0947\u0902 \u092e\u094d\u092f\u0942\u091a\u094d\u092f\u0942\u0905\u0932 \u090f\u0915\u094d\u0938\u0915\u094d\u0932\u0942\u0936\u0928 \u0939\u0940 \u0938\u092e\u0938\u094d\u092f\u093e \u0915\u095c\u0940 \u0915\u0930 \u0926\u0947\u0924\u093e \u0939\u0948\u0964<\/div>\n
<\/div>\n
\u0905\u0917\u0930 \u0925\u094d\u0930\u0947\u0921 \u0915\u094b \u092a\u094d\u092b\u094d\u0932\u0948\u0917 \u0905\u092a\u0921\u0947\u091f \u0915\u0930\u0928\u0947 \u0915\u0947 \u0926\u094c\u0930\u093e\u0928 ( current_thread = true \u0915\u0947 \u0926\u094c\u0930\u093e\u0928) \u0930\u0940\u092e\u094d\u092a\u094d\u091f \u0915\u093f\u092f\u093e \u091c\u093e\u0924\u093e \u0939\u0948 \u092f\u093e\u0928\u0940 \u0915\u093f \u0930\u094b\u0915\u093e \u091c\u093e\u0924\u093e \u0939\u0948 \u0924\u092c \u0926\u094b\u0928\u094b\u0902 \u0939\u0940 \u0925\u094d\u0930\u0947\u0921 \u0905\u092a\u0928\u0947 \u0915\u094d\u0930\u093f\u091f\u093f\u0915\u0932 \u0938\u0947\u0915\u094d\u0936\u0928 \u092e\u0947\u0902 \u091a\u0932\u0947 \u091c\u093e\u0924\u0947 \u0939\u0948\u0902\u0964<\/div>\n
<\/div>\n
\u092b\u093f\u0930 \u091c\u092c \u092a\u094d\u0930\u0940\u092e\u094d\u092a\u094d\u091f \u0915\u093f\u092f\u0947 \u0939\u0941\u090f \u0925\u094d\u0930\u0947\u0921 \u0915\u094b \u091c\u092c \u092b\u093f\u0930 \u0938\u0947 \u0936\u0941\u0930\u0942 \u0915\u093f\u092f\u093e \u091c\u093e\u0924\u093e \u0939\u0948 \u0924\u094b \u0907\u090f \u0938\u094d\u091f\u093e\u0930\u094d\u091f \u092a\u0930 \u092d\u0940 \u0910\u0938\u0947 \u0939\u0940 \u0926\u0947\u0916\u093e \u091c\u093e \u0938\u0915\u0924\u093e \u0939\u0948 \u091c\u092c \u0926\u094b\u0928\u094b\u0902 \u092b\u094d\u0932\u0948\u0917 false \u0939\u094b \u091c\u093e\u090f\u0901\u0964<\/div>\n
\u0921\u0947\u0915\u0930 \u090f\u0932\u094d\u0917\u094b\u0930\u093f\u0925\u092e \u0915\u093e \u0924\u0940\u0938\u0930\u093e \u0935\u0930\u094d\u091c\u0928<\/h3>\n
\u092e\u094d\u092f\u0942\u091a\u094d\u092f\u0942\u0905\u0932 \u090f\u0915\u094d\u0938\u0915\u094d\u0932\u0942\u0936\u0928 \u0915\u094b \u092b\u093f\u0930 \u0938\u0947 \u0938\u0941\u0928\u093f\u0936\u094d\u091a\u093f\u0924 \u0915\u0930\u0928\u0947 \u0915\u0947 \u0932\u093f\u090f \u092f\u0947 \u092b\u094d\u0932\u0948\u0917 \u0915\u094b \u090f\u0902\u091f\u094d\u0930\u0940 \u0938\u0947\u0915\u094d\u0936\u0928 \u0938\u0947 \u092a\u0939\u0932\u0947 \u0939\u0940 \u0938\u0947\u091f \u0915\u0930 \u0926\u0947\u0924\u093e \u0939\u0948\u0964<\/p>\n
\n
Main()<\/code><\/div>\n{<\/code><\/div>\n<\/div>\n
\/\/ flags to indicate if each thread is in<\/code><\/div>\n\/\/ queue to enter its critical section<\/code><\/div>\nboolean thread1wantstoenter = <\/code>false<\/code>;<\/code><\/div>\nboolean thread2wantstoenter = <\/code>false<\/code>;<\/code><\/div>\n