![]() |
|
#1
|
|||
|
|||
Simulate the scheduler component of an Operating SystemHi everyone...i am actually new in the world of C. Now the thing is i got an assignment as my class project where i have to write the code to simulate the scheduler component of an Operating System by C. As a processing model my professor selected the example of line at the bank: which involves the use of a single queue but multiple tellers (Processoers).
Can anyone please help me or guide me. I am seeing dark around myself. Regards |
|||
|
#2
|
|||
|
|||
Re: From FaisalQuote:
Obviously, you are not at the beginning of an introductory programming course. So, in order to, maybe, get some clues as to how anyone might be able to offer some suggestions, I have a few questions for you: What is the subject of the class? (Queuing theory or what?) What department? (Computer Science? Engineering? What?) What are the prerequisites for the class? (Mathematics? Computer Science? Programming? What?) What is your programming background? (CS Major? Math Major? What?) Since you are new to C, could you tell us about which languages you have had before? What references to you have from class? (Textbook(s)? Web Reference(s)? What?) Regards, Dave |
|
#3
|
|||
|
|||
Re: From FaisalHello Dave...Thanks for ur concern. Look the subject of the class is “Operating System”. And it is offered by the Computer Science Department. Yah the prequisite for this course was Programming and my background is Information Technology. I have done C, Java, a little bit Perl, PHP and Prolog. The text book for this course my Prof. is using “Operating System-3rd Edition by Gary Nutt”.
My problem is I know C but I didn't work much on the C-Structure. Specially the kind of project I have right now. In the project the Prof. Ask me to create a C program that simulates the Scheduler component of an Operating System. The scheduler will be based upon a real-life situation such as A line at the Bank: Which involves the use of a single queue but multiple tellers (Processors). It will be great if I can see some samples about how to write Schedulers with various processes by C language. Then I guess I can go on... Regards |
|
#4
|
|||
|
|||
Re: From FaisalQuote:
Wow...this is a bit of a strange assignment from the perspective of the "processing model." Typically it is easier to think of a single processor "model" with multiple queues where various tasks are managed by their positions in the various queues. For example, some tasks may be blocked, others may be ready to run and others may be in transition between ready to run from being loaded or exiting. Logically, if one thinks of the line of people waiting to be serviced as "tasks" and the tellers as being "processors," then "in real life" it wouldn't be a very efficient multi-processor operating system. I suppose that those tasks in the queue are always ready to run and simply are waiting on a processor to service them. This is almost exactly backwards of "real" OS design. Where the "tellers" are tasks in various states of their execution of the work they've been given to do by their code and the "line" is really a "ready-to-run" task queue waiting for processor time. Even in the situation where there is a dual core processor, there may simply be "two lines." Any way...interesting problem/challenge. I'd probably start by creating the data structures needed to represent the various elements in the system. If you follow the model of the bank line, then I'd name these structures based on their physical representation of their "place" in the model you've been given. For example: "Teller" "Customer" "Line" Where Teller perhaps displays the "Customer.Number" and the "Customer" then "exits." The "OS" then provides the Teller with a new Customer from the Line. Maybe something like this: CPP / C++ / C Code:
Output: Code:
:davis: |
|
#5
|
|||
|
|||
Re: From Faisal...it looks like I've got the logic that displays the menu somewhat screwed up...oh well, that's what I get for such a quick hack. Shouldn't be too difficult to fix. (Perhaps due to not clearing the the buffer on each pass?)
:davis: |
|
#6
|
|||
|
|||
Re: From FaisalDavis, man........ u really deserve more than a Normal Thanks....U r great dude....!!! Special Thanks from me. (http://faisalnet5.blogspot.com/)
|
|
#7
|
|||
|
|||
Re: From FaisalQuote:
Nah... What would be fun would be to make it multi-threaded and then randomize the amount of time that it takes for each customer to be serviced by various tellers adding a weighting factor based on "teller individual productivity" and then see the "scheduler" working "for real." ...and then, insert a signal handler so that the user could break the execution to display the menu at any "interrupt." ...then add context switching and add other random events like tellers going on break, visiting the restroom, answering the phones, going to the vault, getting supervisor approval, etc. ...and then, one of the tellers would also be a "supervisor" who would have to "shell out" from the "teller task" to perform the "supervisor task" and then return to the teller task...preemption, priority inversion, synchronization primatives...all good fun! Oh well, probably a bit overly ambitious for a 10-minute hack! Let me know when you're ready to add some AI so that your tellers are able to learn from their customer interactions, supervisor interactions and "competitive" teller performance! Autonomous Teller Agents! Oh Yeah! ...next is adding the OpenGL and shrinkwrapping :davis: |
|
#8
|
|||
|
|||
Re: From FaisalHello Davis...related to my earlier problem I do have some other requirements, for which I actually need help. In the requirement it is mentioned that the whole scheduler simulation program has to run for 8 to 10 minutes. It can read the input from a file or it can randomly generate Processes to start the simulation. After the simulation starts it has to go through all the six main phases what the actual simulation does such as READY, RUNNING, HALTED, SUSPENDED, BLOCKED as well as TERMINATED. Finally...the requirement says there will be a output (short of like log) file where it will show each and every phases status with the following information: Total number of processes, Average wait time incurred by the process and average total time for each process.
Now can u help to get a clue about how can I run the simulation for 8 mins? Suppose there is only one input file.......each line in that file will be my single processes. Then how to come up with the ideas??? Then I need help to generate those stage and connect with the output file so that whenever any stage starts or changes, it will show in that output file with the final information. Can u give me some hits dude? Regards |
Recent GIDBlog
Problems with the Navy (Enlisted) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The