cs final

0.0(0)
studied byStudied by 1 person
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/115

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

116 Terms

1
New cards
2
New cards
src=

location
3
New cards
* ▪  You’ll find lots of these in nearly every web site you visit
* ▪  Normally, when you develop a web site you’ll place all of the Javascripts that you need in a what and use the
folder
4
New cards
Built-in libraries

* ▪  Javascript comes with several important libraries what
* ▪  The what define some of the often-used features in the language
pre-installed

libs
5
New cards
Date examples

* ▪  We use the Date library to (you guessed it) what
* ▪  The library includes an object called what

▪  An what is simply a collection of variables and functions that provide an easy way to access them

* ▪  The Date library has quite a few functions to work with dates
manipulate dates

Date

object
6
New cards
▪  Time in most programs and computers is stored as the number of milliseconds elapsed since January 1st, 1970

▪  The UNIX operating system was ‘born’ in what, and so the system designers knew that nothing could have happened (in the UNIX world) before 1/1/70

▪  The what evolved into an international standard for keeping time

▪  Unfortunately epoch time is stored in a what-bit number, of which one bit is used a sign (plus or minus)

▪  Recall that 2^31 = 2,147,483,648
1970

epoch

32
7
New cards
▪  Time literally runs out on that date and will ‘what’ to December 13th, 1901

▪  Fortunately we have time to fix the problem by moving to a what-bit storage unit for time measurements
wrap

64
8
New cards
▪  That program returns a fraction number of days until we’re done with the semester

▪  What if we wanted to round it to a whole number of days?

▪  The what can do this and quite a bit more

▪  Math is where you’ll find trig functions (sine, cosine), random numbers, mins and maxes, absolute value, and so on

▪  Let’s use the round( ) function in our program...
Math library
9
New cards
Other popular libraries

▪  There are literally thousands of JS libraries available that do almost anything you can imagine, especially for web page design

▪  Some popular ones include Closure, JQuery, Angular, Mongo, and Node

▪  In CS, we spend a lot of time just learning acronyms and names of what!
programming libraries
10
New cards
Bottom Line

▪  Normally when we want to achieve some effect or computation, it’s been done before and we can find a what to do it

▪  If the exact problem hasn’t been solved, we can modify an what one

▪  It’s pretty rare now in commercial programming to invent something from what

▪  (Though when you do you can get rich!)
library

existing

scratch
11
New cards
The HTML DOM
document object model
12
New cards
▪ The DOM is a way to represent the parts of a what

▪ It acts as a what to any given element

▪ Relationships among the elements are also shown

▪ We use the DOM to find things in an what document
document

map 

HTML
13
New cards
▪ Most HTML tags can have an attribute called what ▪The id attribute allows us to work directly with an what and its contents from Javascript ```javascript

Some text

```
“id”

HTML tag
14
New cards
Clicking a button

▪Let’s say we want to put a button on our HTML page and have a message pop up when someone clicks on the button

▪  We can tell the button to run a what when it is clicked

▪The **what** event is just one of many that we can respond to on the page

▪When the button is clicked, the function say Hello()will run

▪  We still need to write sayHello(),though...
function

onClick
15
New cards
▪In your HTML page, Javascript goes in theof your page in between what tags
16
New cards
Other HTML / DOM events

▪There are many, many events that can be listened for, such as

▪ onBlur: The mouse point is moved what an element

▪ onMouseDown/onMouseUp: what of the mouse

▪ onFocus: Clicking inside an what

▪ onDblClick: what clicking

▪ onLoad: When the what
across

Clicks

input box

Double

page loads
17
New cards
Getting a value from a box

▪The **what** function is very commonly used in creating dynamic web pages...pages that the user can interact with

▪There are actually several ways to address an individual HTML tag, but for the most part you’ll use this one

▪Once you are working with an HTML tag in this way you can change the content of the tag, change its color or font, reposition it, make it appear or disappear, and so on

▪In this instance we are interested in seeing what someone has typed into an what
getElementById 

input box
18
New cards
Getting the values

▪In each type of input, we can fetch the value using GetElementById() and the **what**

▪Once you have a value from a box, your function can treat it just like any other variable
**value** property
19
New cards
Values that are numbers

▪  Text boxes contain just that...text

▪If we want what is in a text box to be treated as a number in Javascript, it needs to be what

▪The Number function will do that for us; there are several other ways, but this is the easiest to remember


```javascript
var z = Number(document.getElementById('box1').value);
```
converted
20
New cards
Setting the value of a box

▪By using a text box’s id we can change its value from what

▪ In this case rather than retrieve the.value we are what it
javascript

setting
21
New cards
▪ what like this is pretty common

▪You can do it for just about any HTML tag, such as a what

▪You also can set things like what values(colors, fonts, position and so on )
Setting values

paragraph

CSS style
22
New cards
Bottom line

▪We use functions, called what, to respond to actions taken by a user on the web page (clicking, dragging, and so on)

▪The most common way to set or read the value of something on a web page is to use a combination of its **what** and its **what** properties

▪  Every element on the page is accessible from Javascript

▪It isn’t just HTML, but also CSS(styles)that we can get to from Javascript

▪Because we are linking Javascript and HTML together, we are now able to essentially ‘program’ our what
listeners

id, value 

web pages
23
New cards
JS variables

▪So far we’ve seen some simple and some more complex JS variables

* let aNumber = 42;
* let firstName = “Perry”;
* let eggs = \[‘white’, ‘blue’, ‘pink’\]; (index, so ‘blue’ is at index 1)

▪We can do some fairly interesting things with just this level of what
**complexity**
24
New cards
The real world

▪  The real world, though, isn’t usually so simplistic

▪Most problems that we are trying to solve are much more complex and need an additional level of what

▪We like to think in terms of things that we know...an egg carton, a store, a person, and so on
functionality
25
New cards
▪ Programming with these high-level ideas is accomplished with something called an **what**

▪In Javascript, an object is simply a variable that has some additional features

They can hold other variables

They also can hold functions

▪We treat the object as one unit...it is essentially a collection of what
object

variables and functions
26
New cards
▪Even though it is just a collection, we can use an object to model real-world things

▪We like to think of objects having what(also called attributes)and what

▪The objects can ‘what’ with one another and with the program

▪  This approach is called what (OOP)
properties, behaviors

communicate

object-oriented programming
27
New cards
‘Other variables’ = Properties

▪In the object world we say that an object has **what**, which is just a fancy name for ‘a collection of variables’

▪For example, we might want to create an egg carton object that stores the number of compartments it has in a what

▪  ‘nouns’
properties

variable
28
New cards
‘Behaviors’ = what

▪Object have properties. They also have behaviors, which are the methods (functions) than an object contains

▪We might, for example, want our egg carton to be able to print out how many slots it has

▪  ‘verbs’
functions
29
New cards
▪When we work with objects, it’s normal to have more than one of the same kind ... several egg cartons, for example

▪It’s quite likely then that two individual objects have the same variable name inside

▪We use the key word **what.** to specify that we are talking about the variable in this object, not some other object
this
30
New cards
Object modeling

▪With just these two simple things(functions and properties)we can do some pretty detailed what of actual things

▪Modeling usually comes down to asking questions like a four-year- old... “Why?” and “What’s that?”
modeling
31
New cards
What if we want more than one?

▪Most of the time, when we work with objects we will use more than just one of them

▪  In the egg example, we created just a single egg

▪  How about a whole carton of them?

▪  We need some way to use the egg object as a what-a cookie cutter - that we can use to make more eggs
pattern
32
New cards
Constructing objects

▪  Fortunately there is a way to do just that

▪  A special kind of function, called a **what**, is used to make a new object based on the original object’s pattern

▪It looks similar to creating just a single object, but uses a what instead of a variable...
constructor

function
33
New cards
What’s the difference?

▪ In the first example, using **what**, we create one egg

▪Using a constructor function as in the second example, we can create as many eggs as we want
let
34
New cards
▪  What we’ve done is to take a real-world problem and model it using what

▪  This is a typical approach to problem-solving with what

▪We could use this kind of simulation to create guidelines for the loading dock workers

▪The kind of program we wrote, using objects, is called what
Javascript objects

software

object-oriented programming
35
New cards
Why OOP is important

▪  Object-oriented programming lets us design objects that mimic real-world things

▪We can write the code and test it, and then use it over and over in new programs to solve new problems

▪For example, maybe next month we need to work out the best arrangement of eggs on a grocer’s shelf

▪We already have a tested egg object...we can just use it again for the new project

▪ This is called **what** and is a big time and money saver
reusability
36
New cards
Bottom line

▪  Not all languages are what

▪  In fact, Javascript is in a what between non-OO
 and very strict OO

▪  A strict OO language would be what

▪Even so, we can use Javascript very effectively to write OO code...

▪OO is more of a mindset and approach than a language feature

▪  The fun part of programming is solving real problems!
object-oriented

middle ground

C++
37
New cards
The id attribute

▪ Most HTML tags can have an attribute called“what

▪The id attribute allows us to work directly with an what and its contents from Javascript
id

HTML tag
38
New cards
▪There are other ways to identify and work with HTML elements besides the ‘id’ attribute: ▪‘what is similar to ‘id’ but is now deprecated(not recommended) ▪ ‘what’ lets us define a ‘kind’ of HTML tag ▪We can also work with all of a specific tag, for example we can apply a style to all

tags ▪It is also common to group things on the page together in order to treat them as one what

name

class

unit
39
New cards
HTML
▪ A what is a section or division of your document ▪ The div groups parts of your page into a logical unit ▪ We use divs for two main purposes •To apply what (color, font, and soon)to a group of elements • To provide what
‘div’

styles

positioning
40
New cards
and style ▪Imagine you have several items that you want to stand out on the page ▪We can group them in a div and apply background and foreground colors to all of them ▪ The trick is to use a
in combination with a **what**
class name
41
New cards
style

▪ An enormous number of style choices is available

▪ What we’re using here is what (CSS) 

▪ Here’s a CSS style that applies to header tags
Cascading Style Sheets
42
New cards
Individual style ▪So, we can change the style of a section of a page using a what,or an entire group of items such as

,

, and so on ▪What if we want to just change the style of one thing, like a single paragraph?

43
New cards
CSS style selectors

▪There are three ways to select something that you would like to style...called **what**, logically enough
selectors
44
New cards
▪ The CSS selectors are:

* No selector character - all tags of that what
* # selector - match a specific what
* . selector - match a what
type

id

class
45
New cards
What’s the class thing?

▪  The what matches a class

▪ Classes let us mark certain parts of a what as having some interesting property

▪For example, we might have a class called warning that would make any text in that class bold and red
.selector

page
46
New cards
▪You can combine the two styles to make a paragraph bold, red AND italic

▪Simply list the style what you want to use, separated by a what
classes, space
47
New cards
We’ve seen that the ‘.’ selector identifies a class to style ▪We can refine this by combining an what selector such as ‘p’ with a what selector...this one makes any

tag

element, class
48
New cards
and position ▪  The
...
tags identify a block of elements on your page ▪We use the **what** attribute to tell the browser where we want the block to appear ▪We also often use the **what** and **what** attributes to tell the browser how wide and tall we want the block to be.
position

width, height
49
New cards
▪ There are two basic ways to position

•what: put the block in a position up, down, left, or right from where it normally would go

•what: specify the x, y coordinates where you want the block to start (0,0 is upper left)
relative

absolute
50
New cards
and templates ▪  One way to design a page’s layout is to use
tags and CSS classes to identify and position the major elements ▪  One
for menus, another for sidebars, another for feature content and so on ▪  This way as we write content, we can simply apply a class to the div to put the item in the correct spot on the page ▪  This separates content from what, which is a good thing!
layout
51
New cards
Styling by attribute ▪  There’s one more way to style a group of elements: When something happens ▪For example, a hyperlink(thetag)can have been visited or not, can be hovered over, and so on ▪We can apply a style to each of these states with the**:** what
selector
52
New cards
Styling links ▪ Hyperlinks(theor what)can be styled
anchor tag
53
New cards
Background images

▪One last stylistic thing to talk about: Placing an image or color on the what of the page

▪Both are attributes of thetag and can either be specified in the tag itself or on a CSS selector
background
54
New cards
Bottom line

▪  HTML separates the structure of a page from its what

▪  CSS separates the style of a page from its what

▪Together, HTML, JavaScript, and CSS allow us to create a rich user experience on web pages

▪We’re seeing a blurring of traditional stand alone applications and web pages

▪  We refer to these as ‘mobile’ apps

▪They combine web design and programming with old school coding

▪There’s still a place for traditional apps, but mobile apps are growing rapidly
content

content
55
New cards
The big two

▪Much of computing involves manipulating data in some way

▪ We gather, organize, store, and retrieve it

▪ Many times we want to **what** the data in some way

▪ Usually we want to **what** the data for an item

▪Searching and sorting are the ‘big two’ algorithms in computers cience
sort

search
56
New cards
But first

▪There are many approaches to search and sort algorithms

▪ We need some way to compare their relative what

▪We can look at the time it takes to search or sort a given number of items

• One way would be with a what

• It’s CS, so we need something more complicated
performance

stop watch
57
New cards
Big-O notation

▪It’s possible to predict with fair accuracy the performance of an algorithm by reducing the programming code into what

▪The equations can be used to evaluate the time it takes to run a search or sort using an algorithm for 1 item, 10 items, 100, items and so on

▪We’re interested in how the algorithm performs as the number of items approaches infinity
mathematical statements
58
New cards
▪ The total time is n(outerloop)\*n(innerloop)=n2 

▪ As n gets bigger, the time what
grows exponentially
59
New cards
▪  Typical algorithms result in expressions like



time=n2 +n+5

▪  As the number of items(n)gets larger, then 2 portion gets larger faster than the n portion

▪  We can say that the algorithm is bound by the n2 portion

▪  We write this as O(n2), and say it is **what**
order n^2
60
New cards
▪ For small n, the two algorithms perform roughly the same

▪As n gets larger, though, the O(n) algorithm takes what to perform

▪If we knew we were going to work on large amounts of data, we’d choose an O(n) approach over an O(n2) approach
less time
61
New cards
Sorting

▪Now that we can talk about performance, let’s look at a few common ways to sort data

▪Our examples will use just a few data points, but remember that it’s the performance for large n that is important

▪  We’ll look at

• what

• what

• what
Insertion

Selection

Divide-and-conquer
62
New cards
▪An what is the sorting you do when you place a hand of playing cards in order

▪We look at each value in turn, from left to right, and place the value in to the correct spot

▪If we have to insert a value, all the values to the right of the insertion point have to move up one
insertion sort
63
New cards
Insertion sort performance

▪ Best-case: The array is already what

• We visit each element once, and no further action is required

• This is O(n)• Worst-case: The array is in what order

• We visit each element, then have to move all the remaining elements over

• This is O(n2)

• When we evaluate an algorithm we typically are interested in its what performance
sorted

reverse

worst- case
64
New cards
Selection sorting

▪Similar to insertion sort, in that we visit each element in the array once

▪  We go all the way to the end, looking for the what

▪  When it’s found, we swap it with the item in the\[0\]position

▪Then starting with\[1\], go all the way down the array to find the smallest item and swap it with what is in \[1\]

▪  This continues until we run out of unsorted items
smallest item
65
New cards
Selection sort performance

▪  We can see that there will be an n2 factor, so it ends up being O(n2)

▪Selection sort is simpler to write, but is generally slower than what for large n
insertion sort
66
New cards
? sort

▪  It’s another compare-and-swap algorithm, so-named because the values what into their correct position

▪ Start at the front of the array and compare what values

▪If the values are in reverse order(6 and 2, for example),swap them so that they are correct (2 and 6)

▪  Move to the next pair and swap if necessary

▪In each pass through the array, the largest value bubbles to the what, so we look at one fewer values each time
‘bubble’

adjacent 

top
67
New cards
Performance of bubble sort

▪  It’s roughly the same as the previous two...we look at n-1, then n-2, then n-3 items and so on

▪  It’sO(n2)again

▪This one is the worst of the lot...for large n it is much what than insertion sort and a little slower than selection sort
slower
68
New cards
Merge sort

▪  This is a divide-and-conquer method in which the array is repeatedly split into what, until the result is a set of 1-element arrays

▪  The small arrays are then sorted and what

▪  As the merge happens, the small, already-sorted arrays are combined in the proper order

▪  Finally the entire array is reassembled in sorted order
smaller arrays

merged
69
New cards
Performance or merge sort

▪  Finally we get to a decent performer!

▪Because the array is split into two pieces in each step, performance ends up being the logarithm base 2 of the number of items, or O(n log2 n)

▪This is fair performance for large n, and certainly what than the prior algorithms
better
70
New cards
Searching

▪Searching algorithms tend to be a little what than sorting

▪Usually the items to search are in an array or a list of some kind

▪It’s generally the what(array, list, etc)that dictates the performance
simpler 

container
71
New cards
▪  In a what, items are store sequentially

▪A linear search starts at the top of the list and looks at each item in turn to see if it is the sought-after item

▪  If there are n items in the list, worst-case is that the one we want is the last on in the list, so we look at all n items

▪  Thus, a linear search is O(n)

▪  By the way, on average it’s O(n/2)
linear search
72
New cards
Hashed searches

▪A what is simply away to generate a unique number for a data item

▪The data is input to a hash function, which returns an what
hash

index value
73
New cards
▪  The index value can be used as an index into an what

▪Here, phone numbers for the four individuals are stored in the hashed array

▪Performance is excellent...the hash function gives us the index into the array, so there’s only one step...it is what (we say it is constant time) and independent of n
array

O(1)
74
New cards
Problems with hashing

▪It’s hard to beat the performance of a properly hashed data set

▪However, creating a good hash algorithm is very difficult..there will almost always be what

▪A collision occurs when two data items generate the same hash value

▪  We handle this by doing a what...the hash provides an index into an array, and each element of the array contains a list to search

▪This is still much faster than a simple list, since the hash function tries to distribute the data as evenly across the array as it can
collisions

two-level search
75
New cards
Hashing and passwords

▪  Hashes are commonly used to secure what for sites and apps

▪  When you sign up, the password that you choose is not stored

▪  Instead, the what value of the password is stored

▪  When you log back in, the site or app hashes the password that you present and compares it with the stored hash value — they should match

▪  If you forget your password, there’s no way for the site to send it to you, since they don’t store it

▪  This is why you will be provided a link to create a new password if you forget the old one

▪  (And BTW if you are on a site that does send you your password, assume it has been hacked!)
passwords 

hash
76
New cards
▪In what data are stored in a structure that looks like this:

▪  To search, we start at the top,
 and then move left or right
 depending on whether the 
data we are looking for is
 what than the item
 we are currently looking at
binary searches

larger or smaller
77
New cards
▪The trees are built from a source set of what...inserting data into a tree is just like what for something (left, right and so on)

▪A properly constructed tree(called a balanced tree)has what numbers of items on each side

▪  A balanced tree can be searched in O(log2n)time

▪  This is very what...recall that


log2 (4,294,967,296) = 32

▪In other words, we can find any item in a tree of 4 billion items in just 32 steps!
data, searching

equal

fast
78
New cards
Bottom line

▪There are many, many more algorithms for both searching and sorting

▪Choice of algorithm depends on the what of the data set, the complexity you are willing to bear, the type of machine that is being used, and other factors

▪Often we’ll try several algorithms and measure their performance on real data in order to choose the best fit

▪None the less it helps to have a general idea of how a class of algorithms will perform
size 
79
New cards
What it is

▪An operating system is a program, just like Powerpoint, Safari,Internet, Explorer, and so on

▪The what is more important than all of the other programs on the computer in that it what all of them

▪The OS hides all of the details of the actual hardware from running programs and provides access to that hardware

▪ This is called what
operating system

controls

abstraction
80
New cards
What it isn’t

▪The operating is what the windows and menus and such that we see when we use the computer

▪These are also programs running on the computer, controlled by the operating system (OS

▪Some operating systems are more tightly integrated with the windowing environment than others

\- Windows: what integrated- 

Linux: what integrated- 

MacOS: Somewhere in what
NOT

Tightly 

Loosely 

between
81
New cards
Evolution

▪  Early computers were what...they ran just one program

▪As they evolved, there was a desire to be able to switch easily between programs, though it was still manual

▪Early main frame computers were extremely expensive, and no one wanted to waste the CPU’s valuable time by having it be idle

▪ 90% percent what was often a target

▪It took time to manually switch programs, which cut in to utilization

▪Automated ways of switching between programs evolved into out modern what
single task

utilization

operating systems
82
New cards
What the OS does

▪ The operating system has four primary jobs

what are they?
1\. Scheduling \n 2. Hardware abstraction / access

3\. Memory management \n 4. Files and directories
83
New cards
Job 1: what

▪The hardware component that executes programs is the CPU(central processing unit)

▪Our computers are what: They run many hundreds of programs at what looks like the same time using one CPU

▪Some computers are what: They contain more than one CPU or CPU core and also multitask on each CPU.
Scheduling

multitasking

multiprocessing
84
New cards
▪There has to be some sort of controller to choose which of the hundreds of programs gets to run

▪Part of the operating system is called the **what**...it chooses which program runs next

▪(A note... we usually don’t talk about ‘programs’ but rather ‘processes’. A process can be an entire program or part of a program)
scheduler
85
New cards
Multiprocessor CPUs

▪  In a computer with a single CPU, only one process can run at any given time

▪  In multiprocessor computers there can be **what** running at a time in **each** CPU

▪  Some CPUs have more than one **what**, which is essentially a mini-CPU inside the CPU chip

▪ Example: an Intel i7 quad-core has four CPU cores inside the i7 CPU chip

▪ If we have a i7 quad core with two threads per core, we’d potentially be running four programs (processes) simultaneously, and each process would have up to two threads of execution
only one process

core
86
New cards
▪To be fair, each program that wants to run is given an equal amount of time to execute in the CPU, called a what

▪  Quantum is short...on MacOS, for example, quantum is
 10 milliseconds

▪This means that every 10 ms a different what is running...100 programs per second!

▪The OS scheduler chooses a new program after each quantum what
quantum

program

expires
87
New cards
▪Because the switching is happening very quickly, it appears to us that all of our programs are running what

▪Really it’s just an illusion... a CPU core can run only one process at a time

▪  This is similar to a motion picture—really a movie is a series of still images, but they are played back so quickly that we don’t see individual frames but rather the appearance of motion
simultaneously
88
New cards
▪When a program does something really slow, such as request to read rom disk, what should the OS do?

▪This is called what... we don’t want to waste the CPU’s time by waiting for the disk read

▪When a blocking event happens, the scheduler immediately chooses another program to run

▪  The program that blocked goes to what
blocking

sleep
89
New cards
▪In a computer, an what is an event that needs immediate attention

▪ Some examples:

\- the mouse moves or clicks

\- a key is pressed on the key board 

\- an internal timer goes off

\- a disk read or write completes

▪ On OSX we can see interrupt counts with the what
interrupt

latency command
90
New cards
▪Each time an interrupt happens, the currently running program is pulled out of the CPU and an interrupt service routine (ISR) is moved into the CPU to run

▪The what takes care of the the event... if it’s a key stroke, for example, it figures out which key and stores it for later processing

▪Once the ISR is done, the interrupted program is allowed to use up the rest of its what
ISR

quantum
91
New cards
Scheduling schemes

▪Since there are so many programs wanting to run, the scheduler tries to be fair

▪  It chooses from all those programs that are in the ready state, sometimes called the what

▪These programs are ready to immediately start running in the CPU

▪  One way to schedule is round robin...A,B,C,D,A,B,C,D and so on

▪  Of course, this being CS, round-robin is too simple
runnable state
92
New cards
▪ What if one program is more important that another?

▪ What if a program has been sleeping a long time?

▪ What if a program is new and just starting up?

▪Most OS schedulers use a what to handle these cases
priority system 
93
New cards
Example: what

▪Imagine Program A finally gets to run...then it almost immediately calls for a disk read and is blocked for several hundred milliseconds

▪Program A is sleeping all this time, but all it needs is for the read to complete

▪Once the read is done, Program A is woken up and given a very high priority, so it will likely be picked by the scheduler very quickly
blocked program
94
New cards
Starvation

▪If most of the programs running have what, some unlucky programs might never get to run

▪To fix this, each time the scheduler runs, any program that has been waiting gets its priority what

▪Eventually even the unlucky program will run (and, since it is unlucky, will immediately block)
relatively high priorities

bumped up
95
New cards
Real-time priority

▪ Many programs have a super-high (real-time or RT) priority because they MUST run when they are ready...maybe one is controlling the thermostat on the nuclear reactor core

▪ Another RT program is the ISR for the scheduler timer

\- Every 10ms the timer goes off

\- The next thing to happen is a scheduler run

Scheduler must run at each quantum expire and so the ISR that starts it is given what
RT priority
96
New cards
Scheduling speed

▪  The what is some of the fastest code in the OS

▪  It has to be..it runs constantly, over and over

▪The scheduler is not doing any useful work, at least not in the sense that regular programs do...it is just doing housekeeping...the time it spends running is overhead

▪Moving programs in and out of the CPU is called what and is also overhead

▪OS programmers spend considerable effort tweaking the scheduler and switching programs
scheduler

context switching 
97
New cards
Job 2: ?

▪  No sane OS would allow user
 programs to directly access
 hardware such as the printer, the
 disk drives, and so on

▪  For one thing, a large number
 of programs need to use these what

▪  For another, it’s just safer 
if one what manages
 access to these things
Hardware abstraction / access


limited resources

gatekeeper
98
New cards
Making a call for hardware: Disk

▪  Program A is running and needs to write to what

▪Instead of writing directly to the disk controller, Program A asks the what to do the write in its behalf

▪This is a blocking i/o call, and so Program A is switched out and sleeps, and the OS code that handles disk requests starts to what

▪  The OS code asks the what to do the write

▪  The scheduler now runs and the next program is given the what

▪Once the write is complete, an interrupt is generated; the ISR wakes up Program A and increases its what
disk

OS

run

disk controller

CPU

priority
99
New cards
▪Since the hardware is abstracted by the OS, the application program doesn’t need to know the details of the what

▪All the application program does is to ask the OS to do the what

▪Our application programs are simplified and more flexible because of the what
disk drive

read or write

abstraction
100
New cards
▪  The what (HAL) sits between the OS and the physical

▪  This allows OS programmers to write their code against a what without having to worry about what hardware sits below

▪  The HAL translates requests from the OS into specific what

▪  A huge advantage is that this makes porting the OS to different hardware simple, since only the HAL need be rewritten...the rest of the OS code remains the same

▪  For example, when you install a new graphics card, a software driver is installed that provides the translation between generic calls from programs and the specific instructions for that card
hardware abstraction layer

generic interface

hardware functions