Thread: somebody help me please (with code I found)

  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
    3,445
    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?
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  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
    3,445
    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.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > 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.
    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.

  7. #7
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    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
    4,183
    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.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

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, 04:01 PM
  2. Hi, I found this C code that...
    By DrSnuggles in forum C++ Programming
    Replies: 13
    Last Post: 10-12-2008, 08:57 PM
  3. Pq - Sq - Kq --- Found!!!
    By sean in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 12-02-2002, 07:07 PM
  4. question regarding code found on this board
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 07-23-2002, 08:03 PM