473,387 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Modern Operating System P 105, I can't understand the code

while(TRUE){
while (turn != 0) /* Should here be a semicolon ( ; ) to make while a
NULL repetition? */
critical_region();
turn = 1;
noncritical_region();
}

/* (a) PROCESS 0 */


while(TRUE){
while (turn != 1) /* Should here be a semicolon ( ; ) to make while a
NULL repetition? */
critical_region();
turn = 0 ;
noncritical_region();
}

/* (b) PROCESS 1*/
Aside:

Initially, process 0 inspects turn, find it to be 0, and enter the
critical region.Process 1 also finds it to be 0 and therefore sits in a
tight loop continually test to see when it becomes 1.

End Aside.

My problem: if there is no semicolon following the inner while , then
(a) process 0 , In the code, when the variable turn set to 0 initially,

while( turn != 0) is false, so the following line critical_region is
skipped over !!
then it will entry noncritical_region.

The same ,(b)Process 1
as turn set to 0 inititally, while (turn != 1) is true.
it should enter the while loop,execute critical_region?

It Contradicts with the book!!!
Please look at it and help me,Thank you.

Dec 13 '06 #1
2 1305
On 13 Dec 2006 07:37:37 -0800, "Solo.Wolve" <wa*******@gmail.com>
wrote:

[...]

Actually, if you read *carefully* the book, there is a semicolon, its
written like that :
while (turn != 0) /* loop */ ;
^ here it is, after the comment.
--
al. - epsylon at gmail dot com
Dec 14 '06 #2

epsylon wrote:
On 13 Dec 2006 07:37:37 -0800, "Solo.Wolve" <wa*******@gmail.com>
wrote:

[...]

Actually, if you read *carefully* the book, there is a semicolon, its
written like that :
while (turn != 0) /* loop */ ;
^ here it is, after the comment.
--
al. - epsylon at gmail dot com
I saw it actually.
I mean, the loop is just an empty loop, Or it contains the following
stetement,
critical_region?
If it's not empty loop, I don't understand.

Dec 17 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

32
by: David Brown | last post by:
Hello. I recently came across a free operating system called Unununium (or something like that) and it was developed in Python and Assembly. Now, I have been looking for a way to make an...
27
by: Kevin A | last post by:
Hi, Is there a way to determine the name and version of the operating system in a portable way? (for Solaris/Linux) Thanks, Kevin
10
by: Vavel | last post by:
Hi all! I want to insert the record into the table by using an application program that includes the following statements: EXEC SQL BEGIN DECLARE SECTION; long hvInt_Stor; long hvExt_Stor;...
2
by: seash | last post by:
H iam developing my windows form application(ide:visual studio.net 2003, visual c#) on windows 2000 professional operating system , but when i run the exe on Xp operating system, the screen ...
7
by: Saadi | last post by:
Hey Guys, I am looking to develop a simple infact a very simple Operating System, to submit as my BS final project, which can independently start the computer and some simple application which...
78
by: arnuld | last post by:
hai all, i am standing on a "crossroad to C++". I am here in front of you as i have a problem. i will be brief. Please do not think: "arnuld is sick", i am really struggling & doing hard-work to...
0
by: Solo.Wolve | last post by:
while(TRUE){ while (turn != 0) /* Should here be a semicolon ( ; ) to make while a NULL repetition? */ critical_region(); turn = 1; noncritical_region(); } /* (a) PROCESS 0 */
1
by: newstips6706 | last post by:
The Operating System of Organic Machines Building your own "KERNEL". --------------------------------------------------------------------------------
1
by: jdresow | last post by:
I installed MySQL on a windows server 2003, in an acxtive directory domain and I get error 32 which is a sharing error. I do not understand this and I am also adding the first several lines of my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.