Friday, November 23, 2007

os exam revision notes

Scheduling
SJF
SRTF(preemptive SJF)
-must know burst time first
-starvation for longer process

FCFS
RR
Multi-level feedback queue

Critical Section Problem
global turn
-no progess w strict alternation

local flag
-i/o => deadlock

flag + turn
-only works for 2 process

bakery algo
-get ticket of (max + 1)
-run if no one getting ticket and <= to all

Deadlock
Mutex. Hold-Wait. No-preempt. Circular wait

Banker algo.
-needs and resources
-find exec state run all => safe state

Paging
EAT = (A + B)p + (2A + B)(1-p)
A - PT
B - TLB
p - TLB Hit %


Disk Allocation
Contig
+Random Access
-Small file

Linked
-Sequential
+Large file

Indexed
-Sequential
+large file

Max. Disk File
Inode (Add all to find max file size)
-direct = blockSize
-Single indirect = (blockSize/pter size) blockSize
-Mulitple indirect = (blockSize/pter size) (blockSize/pter size) blockSize

Wednesday, November 21, 2007

database revision notes

Cost of Joins

Direct = A + B
[Needs suff memory]

Nested Loop = A + AB
with Buffer = A + Math.ceil(A/Buf-2)*B

Simple Loop = A + RecB [ XindexA + SelCardA ]
[index req]
XindexA : cost to access index
SelCardA = #tuple/#satisfy for A

Merge-Sort = 2A + 2A Math.ceil(log[deg]A) + 2B +2B Math.ceil(log[deg]B) + A + B
[A + B is the cost to join if they are already sorted]

Cost of write back(size of result)
Join Selectivity not known / No PK

JS = 1 / MAX(DistinctValueA, DistinctValueB)

Sz of join = Math.ceil(JS*RecA*RecB/bfr[size of joined tuple])

Minimal cover

1) All RHS only got 1 field
2) Remove each rule and check if can get it back w/o it

B+ tree
B = Block size // fit the nodes into a block
V = sz of key
D = sz of data pointer
P = sz of internal pointers[within node in tree]
p = no. of nodes in a block
Psp = sz of pointer for leaf node pointing to next leaf node(linked list)

Non-leaf node : pP + (p-1)V <= B
Leaf node : p[leaf] (V+D) + Psp <= B

NF
2NF
-no partial dependencies

3NF
-no transitive

BCNF
-Determinant is superkey

Equivalence
a = {A->C, AC->D}
b = {A->CD}

from a, {A}+ -> {ACD} covered {A->CD}
from b, {A}+ -> {ACD} covered {A->C}, {AC->D}
therefore, proven

DB Recovery
Immediate (Undo-Redo) / Defered Updates (Redo)

1) Find last checkpoint
2) 2 lists
-Committed Transaction
-Uncommitted Transaction
[ For Immediate Only
2b)
Analyze dependencies for any cascading and put affected commited to uncommited
-Undo UNCommitted
]
3) Redo commited
4) Restart uncommited

SQL optimise
Cartesian Product
Push select down and restrictive select first
Replace Cartesian Product with join
Push Project down

DB Security
1) Create View
2) Grant [*|select,...] on [table] to [user] [with Grant option]

Tuesday, November 20, 2007

db exam sql

select dest from flight f where not exists
(select LID from airline
except
select lid from flight where dest = f.dest)

select lid from flight group by lid having count(*) >
(select count(*) from flight f, airline a where f.lid = a.lid and name='Lion')

select top 1 aid from airport where aid not in
(select aid from locates l, airline a where l.lid = a.lid and name = 'Lion')
group by aid order by count(*) desc

Wednesday, November 14, 2007

HS811 Crime final review

Becarria / Classical Criminology
Social ecology / area of studies (Consensus)
Merton (anomie / strain) (CS)
Matza
Becker, Chambliss, Cohen, Goffman (interactionist)
Problem of official studies
Sutherland - White collar (CS)
Conflict studies - eg Chambliss, Kolko, Hall (Conflict)
Studies abt woman, including Messerschmidt (INT)
Right Realism - target hardening, ....
Left Realism (Use most of the above theories) [Sq of crime]
Police & Prison

-------------------------------------------------

Essay
-Org
-Start, end pt[Conclusion]

-------------------------------------------------

Overview
Classical Criminology
What give the rights to punish? Equal rights of rational men

Key idea: “rule of law”; justice (equally fair to all – blind to status differences of people, and other differences)

BUT unfortunately we continue unequal in property, etc, so we cannot fully practice the principles

Positivists
What causes criminals? comparing criminals with non-criminals
Control groups may not be valid control groups

Lombroso – born morally inferior.
Sheldon - born aggressive, impulsive, blithely (happily) unconcerned.
Eysenck – born unconditionable.
McCords and Gluecks – are unloved and unsupervised.
Shaw and McKay – are living in an area of mixed values and some criminals living there that one mixes with & can learn from.

Merton
What factors within American society (at structural level) cause criminals?

Strong materialistic values/success, plus structured lack of real opportunities of materialistic success

Sutherland
But, why do we not notice much of the criminality? done at work and it is done by high status people
Other high status people don’t like to send their sort of people into the criminal courts or into prison.
However, it is still done because of mixing with other people who do it.

Interactionists (labeling theory)
asking the wrong questions
“Crimes” and “criminals” are not “definite things”.
Criminals don’t come before crime, they come a long, long time after the first actions that are interpreted as crime.
And actions can only be “interpreted” as crimes if someone makes a law first.

what would-be law makers, & what law enforcers do?
=crusades to make laws, or unmake laws.
=panics about behavior and stop-and-search people ….
=label people

Marxists to Interactionists "Capitalist society”

Feminists: socially constructed “male-ness”

Right Realists: Practical changes instead of theories

Left Realists
Taking account first of those who suffer from the situation most.
And using a square as a way to organize it.”

Post-Modernists: “No ultimate truth"

Past year paper
a)Sutherland White Collar Crime. [how, why impt?]
b)Relevant in SG

1) S defined WCC ... He included ...
2) His studies ... huge amount, unrecorded
3) Impt because middle/high status crime ignored ...
4) but he put together some crimes that may be different ….
5/6) In Singapore,...

Merton vs Conflict
1. Merton focussed on and explaining crime, Conflict theory analysis whole society, crime just small element// or both analyse structures and connection to crime but focussed on individuals who commit crime // or …
[... vs Sub/super structure]
2, 3 Merton theory – [Zone in transition - mixed values, rundown, not well-off to move away, immigrant]
4, 5. Conflict theory –
6. Final summary point, or new point

Square of Crime
1. LR, (L Idealists, R Realists) ..
2. Square of crime – four parts, draw and label it.
3, 4, 5, 6. Look at one “corner” each. Refer to theories that are utilised. E.g. State and social control – Conflict theory, and interactionist theory. Work on prisons, etc.
7. Own view if LR is fully comprehensive. Is anything left out?