Like Tree2Likes
  • 2 Post By Salem

somebody help me please (with code I found)

This is a discussion on somebody help me please (with code I found) within the Linux Programming forums, part of the Platform Specific Boards category; The simulation will consist of two main communicating processes, a producer and a consumer. Functional Requirements First process This process ...

  1. #1
    Registered User
    Join Date
    Mar 2014
    Posts
    3

    Arrow somebody help me please (with code I found)

    The simulation will consist of two main communicating processes, a producer and a consumer.

    Functional Requirements
    First process
    This process will be required to run to create a series of child processes that will represent each of the printer jobs. The PID number of each child is to be inserted / spooled within a priority queue.
    The queue will be made available to the second process to allow de-spooling.
    The process should be configurable using command line arguments such that the size of the queue and the maximum number of jobs to be created during each cycle can be specified.
    It should perform the following functionality

    Create a number of print jobs.
    Assign a priority value to each.
    Insert their details into a suitable data structure.


    Second Process
    This process will be separate from the first and running within a separate console window and will simulate the de-spooling process.
    The process should be configurable using command line arguments such that the maximum number of jobs to be deleted during each cycle can be specified.
    It should perform the following functions:

    Find and delete a number of printer jobs by priority order.
    Print a message to notify the user of the deletion.
    Kill the corresponding process.
    Remove the processís details from the data structure.

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    2,402
    1. How to ask questions the smart way

    2. What have you tried so far?

    3. What problem(s) are you having?

    4. Do you have any code demonstrating the problem you're having?
    Code:
    namespace life
    {
        const bool change = true;
    }

  3. #3
    Registered User
    Join Date
    Mar 2014
    Posts
    3

    :)

    i have attached the file,

    1st of all im getting an endless loop
    now it comiples but does to not show output result once excuteded

    is is possible to change to linklist

    can you help me out please

    thanks
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    2,402
    on line 92 of producer.c, you're checking that the return of fork() is less than 1. fork() returns zero to the child, the child's pid (greater than zero) to the parent, and a value less than zero on error. your code will sleep forever if fork() returns an error, because on line 93 of producer.c , you're doing an endless loop of sleeping for 1 second. it will never break out of this loop. under no circumstances will line 96 ever print.

    in randTYPE(), you're calling srand() every time the function is called. move srand() to main, before you start anything, so it only runs once.

    these are just a couple of things I see. there may be more, but that should get you started.
    Code:
    namespace life
    {
        const bool change = true;
    }

  5. #5
    Registered User
    Join Date
    Mar 2014
    Posts
    3

    :)

    i try to make the changes but still won't give me an output, i dont know why, however i have made the changes that you told me it compile and exute the the progrmam but their is no output i dont know why help me please can you try do it

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,535
    > 2. What have you tried so far?
    "I searched the web, found some code and reposted it as my own work".
    Tidying up Code and Compile Problems

    > 3. What problem(s) are you having?
    "In reality, I'm dumber than a box of rocks when it comes to programming."

    Start writing your own code for a change and stop relying on "google" + "forum nagging" to get your work done.
    Matticus and Hodor like this.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    650
    Quote Originally Posted by Salem View Post
    > 2. What have you tried so far?
    "I searched the web, found some code and reposted it as my own work".
    Tidying up Code and Compile Problems

    > 3. What problem(s) are you having?
    "In reality, I'm dumber than a box of rocks when it comes to programming."

    Start writing your own code for a change and stop relying on "google" + "forum nagging" to get your work done.
    I've been thinking about this. Is using code found using google "cheating" any more than using a library, STL, Boost, or referring to sepples or knuth?

  8. #8
    Registered User
    Join Date
    May 2009
    Posts
    2,571
    Quote Originally Posted by Hodor View Post
    I've been thinking about this. Is using code found using google "cheating" any more than using a library, STL, Boost, or referring to sepples or knuth?
    If you do NOT credit the source it is cheating!

    Tim S.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. run code found on a website ..HELP
    By zebra in forum C Programming
    Replies: 6
    Last Post: 02-09-2012, 03:01 PM
  2. Replies: 5
    Last Post: 04-18-2011, 10:46 AM
  3. Hi, I found this C code that...
    By DrSnuggles in forum C++ Programming
    Replies: 13
    Last Post: 10-12-2008, 08:57 PM
  4. Pq - Sq - Kq --- Found!!!
    By sean in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 12-02-2002, 06:07 PM
  5. question regarding code found on this board
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 07-23-2002, 08:03 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21