Thread: Process Syncronization

  1. #1
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278

    Process Syncronization

    1. Is busy waiting is always less efficient than blocking wait? Explain.
    2. In Bakery algorithm why the loop is used?
    Code:
    while( choosing[j] )do { nothing };
    3. Compare and contrast Dekker's and Peterson algorithms.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    So what effort have you put into finding the answers so far?
    I mean, #3 looks like prime google material.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by anirban View Post
    1. Is busy waiting is always less efficient than blocking wait? Explain.
    You do mean like
    Code:
    while(!busy)
    or
    Code:
    WaitForSingleObject(busy, INFINITE);
    ?
    Second approach uses less CPU which is always a good thing. Is there something else you were thinking of?

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    This is quite clearly some "test" question, so I suggest you refrain from answering, and helping someone who hasn't done their homework/followed the class lectures passing a test they shouldn't.

    By the way, I'm not sure your answer is complete.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Indeed, I'll not elaborate, but the question is if it's blocking like through a loop or waiting with a blocking function? That's what bothers me.

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Yes, the term "busy waiting" usually refers to "waiting by polling".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278
    No these are not test questions! This questions have cropped up in my mind while reading! I have read few books and did not find the answer! I have read Stallings, Dietel, Galvin and Dhamdhere!

  8. #8
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by anirban View Post
    No these are not test questions! This questions have cropped up in my mind while reading! I have read few books and did not find the answer! I have read Stallings, Dietel, Galvin and Dhamdhere!
    And you just happened to phrase them exactly like test questions for some reason? "Explain." That's a test question. "Compare and contrast." That's a test question. I mean who writes like that except if they're writing a test?

  9. #9
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Just bring up the two pages on wikipedia on those two algorithms
    - compare means copy the bits which are the same
    - contract means copy the bits which are different
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  10. #10
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278
    Look whenever I ask questions I ask it in a formal way! I like to ask people in such a way so that they need seconds to grasp what I am saying!

    Now to all I say! This is not the first time when i have been almost teased off for asking a bit theoretical questions! Every time I hope someone will answer my question! Instead what I get such nonsense answers from over-intellectuals who have posted thousands of answers and put some heavy quotations under their name! Now I tell you all, if you cannot answer why you act in such ways? Someone says these are test question, someone says try yourself! Whenever I participate in any forum my philosophy is that if I cannot answer I do not post or make a stupid behavior out of myself as you all have done! I mean I don't have any words to say you all!

    @SALEM
    What the hell are you speaking? What do you mean by those two statements?

  11. #11
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Whatever Salem is speaking, it's certainly more polite than what you are speaking.

    1. http://nob.cs.ucdavis.edu/classes/ec...nc-bakery.html
    It's like this implementation of strcpy(). Why is there nothing in the loop? Because all of the calculation is done in the loop condition.
    Code:
    while ( *a++ = *b++ );
    3. Prime google material indeed.
    http://en.wikipedia.org/wiki/Dekker's_algorithm [edit] CBoard didn't recognize this as a URL! [/edit]
    http://en.wikipedia.org/wiki/Peterson%27s_algorithm

    Scroll down to "Two-Process Mutual Exclusion: Dekker's- and Peterson's Algorithms":
    http://www.isd.mel.nist.gov/projects.../doc/mutex.htm
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  12. #12
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    I see no reason to click on some links to say wikipedia, prepare some words which "compare and contrast", then post it here just so you can run up to your tutor all "bright eyed and bushy tailed" feeling that you really know something, when you really don't.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  13. #13
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278
    @dwks
    Thank you for the links! Could you please tell me that why the while statement is used? What would happen without that while loop?


    @Salem
    Do not act too smart and stop your jugglery of words! If you can answer then reply to any post else not! Posting thousands of replies does not make you something different! Just read what you have replied to the post and then say!

    I know that I have been too indecent but I cannot help myself! There are few members I have seen they have unnecessary habit of interfering in every post even if they do not have answer! They do not provide any answer and upon that and reply all sorts of non-sense statements as few have done above! The reality is that after answering so many posts they have developed in them a pseudo-confidence of knowing everything!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. init adopts zombie process?
    By password636 in forum Linux Programming
    Replies: 4
    Last Post: 07-01-2009, 10:05 AM
  2. create a child process that creates a child process
    By cus in forum Linux Programming
    Replies: 9
    Last Post: 01-13-2009, 02:14 PM
  3. Replies: 3
    Last Post: 10-15-2008, 09:24 AM
  4. Problem with forking a process
    By Unitedroad in forum C Programming
    Replies: 10
    Last Post: 10-04-2007, 01:43 AM
  5. process programming
    By St0rM-MaN in forum Linux Programming
    Replies: 2
    Last Post: 09-15-2007, 07:53 AM