example how can we stop two independent processors from altering some memory

Example how can we stop two independent processors

This preview shows page 22 - 24 out of 102 pages.

example - how can we stop two independent processors from altering some memory location which they both share simultaneously (so that neither of them can detect the collision)? This is a problem in process synchronization . The solution to this problem is much simpler in a single CPU system since no two things ever happen truly simultaneously. We shall consider this in more detail in later chapters. For now it is useful to keep in mind that multiprocessors are an important element of modern OS design. Exercises 1. Write a program to manage an array of many stacks. 2. Describe the difference between the kernel and daemons in UNIX. What is the point of making this distinction? 3. What is two-mode operation? 4. What is the difference between an emulator or simulator and true multi-tasking? 5. To prepare to for the project suggestion in the next chapter, write a program which reads fictitious commands in from a file. The commands should be of the form:
Image of page 22
6. operator operand 7. 8. load 12 9. add 23 10. store 1334 11. jsr 5678 12. wait 1 13. fork 0 etc. Read in the commands and print out a log of what the commands are, in the form "Executing (operator) on (operand)". You should be able to recognize the commands `wait' and `fork' specially, but the other commands may be anything you like. The aim is to simulate the type of commands a real program has to execute. 4. Processes and Thread 4.1 Key concepts Multitasking and multi-user systems need to distinguish between the different programs being executed by the system. This is accomplished with the concept of a process . 4.1.1 Naming conventions Before talking about process management we shall introduce some of the names which are in common use. Not all operating systems or books agree on the definitions of these names. In this chapter we shall take a liberal attitude - after all, it is the ideas rather than the names which count. Try to remember the different terms - they will be used repeatedly. Process : This is a general term for a program which is being executed . All work done by the CPU contributes to the execution of processes. Each process has a descriptive information structure associated with it (normally held by the kernel) called a process control block which keeps track of how far the execution has progressed and what resources the process holds. Task : On some systems processes are called tasks. Job : Some systems distinguish between batch execution and interactive execution. Batch (or queued) processes are often called jobs. They are like production line processes which start, do something and quit, without stopping to ask for input from a user. They are non-interactive processes. Thread : (sometimes called a lightweight process ) is different from process or task in that a thread is not enough to get a whole program executed. A thread is a kind of stripped down process - it is just one `active hand' in a program - something which the CPU is doing on behalf of a program, but not enough to be called a complete process. Threads remember what they have done separately, but
Image of page 23
Image of page 24

You've reached the end of your free preview.

Want to read all 102 pages?

  • One '20

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes