lsli13.4up - 13-1 13-1 13-2 13-2 Operating Systems Denition...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
13-1 13-1 Operating Systems Definition: An operating system is the software that manages re- sources in a computer. Resources A resource is (usually) hardware that needs to be accessed. There are rules for accessing resources . . . . . . rules enforced by the OS. Rules might . . . . . . restrict access to sensitive resources . . . . . . or control access to finite resources. Typical Resources Terminal I/O . Filesystem. (Data stored on disk). Main memory. (A.k.a. RAM or core). Sensors and actuators. (In a RTS, for example.) Network services. (To connect to other computers.) Threads . CPU time . OS description here is for a typical multithreaded of Unix . . . . . . other modern operating systems work in a similar fashion. 13-1 EE 4770 Lecture Transparency. Formatted 13:26, 23 December 1997 from lsli13. 13-1 13-2 13-2 Resources Managed on Behalf Of Tasks . Task requests the resource. OS determines if task is allowed the resource. OS determines if task can be given the resource. E.g. , if there is enough available. If both are true, OS grants the task’s request. To service such requests, the OS must keep track of how much of each resource is available and under what conditions requests can be granted. 13-2 EE 4770 Lecture Transparency. Formatted 13:26, 23 December 1997 from lsli13. 13-2 13-3 13-3 Resource Allocation and Usage Example Consider the following code fragment. /* Allocate 1000 bytes of storage. */ 1: basePointer = malloc( 1000 ) ; The code fragment above is part of some program which is compiled and run on some system. The program, from when it starts running until it finishes running, is referred to as a task. In line 1 the task requests address space (a resource). The task asks the OS for 1000 bytes of main-memory address space using the C malloc library function. The OS checks if the task is allowed 1000 more bytes of address space. The OS also checks if 1000 bytes of address space is available. If both checks are positive, the space is allocated. (If not, malloc returns a null pointer.) 13-3 EE 4770 Lecture Transparency. Formatted 13:26, 23 December 1997 from lsli13. 13-3 13-4 13-4 /* Write a 3 into element x. */ 2: basePointer[x] = 3; /* Open a file for output. */ 3: mf = fopen( "myFile.data" , "w" ); In line 2 task writes to main memory. The task will attempt to write to memory address given by base- Pointer+x . The write makes use of the address-space resource. The system must verify that this resource has been allocated. If the task has write permission to this address, then the 3 is written. Otherwise, the OS will terminate execution of the program be- fore the 3 is written. In line 3 task opens a file for writing, using the filesystem resource. The OS checks if the task has write permission on the file. The OS checks if opening the file for writing could be accom- plished within the task’s resource limits. If both checks are positive, the OS performs all the actions nec- essary to open the file.
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

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