CSE 451: Operating Systems Section 3 Project 0 recap, Project 1.

Slides:



Advertisements
Similar presentations
A C++ Crash Course Part II UW Association for Computing Machinery Questions & Feedback.
Advertisements

1 Designing Hash Tables Sections 5.3, 5.4, Designing a hash table 1.Hash function: establishing a key with an indexed location in a hash table.
CS 11 C track: lecture 7 Last week: structs, typedef, linked lists This week: hash tables more on the C preprocessor extern const.
Constructor. 2 constructor The main use of constructors is to initialize objects. A constructor is a special member function, whose name is same as class.
CSE 451: Operating Systems Section 1. Why are you here? 9/30/102.
CS 177 Recitation Week 8 – Methods. Questions? Announcements  Project 3 milestone due next Thursday 10/22 9pm  Turn in with: turnin –c cs177=xxxx –p.
Memory Arrangement Memory is arrange in a sequence of addressable units (usually bytes) –sizeof( ) return the number of units it takes to store a type.
Tirgul 8 Universal Hashing Remarks on Programming Exercise 1 Solution to question 2 in theoretical homework 2.
More on protocol implementation Packet parsing Memory management Data structures for lookup.
CS 201 Functions Debzani Deb.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
CSE 250: Data Structures Week 3 January 28 – February 1, 2008.
. Memory Management. Memory Organization u During run time, variables can be stored in one of three “pools”  Stack  Static heap  Dynamic heap.
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
§3 Separate Chaining ---- keep a list of all keys that hash to the same value struct ListNode; typedef struct ListNode *Position; struct HashTbl; typedef.
Operating System Program 5 I/O System DMA Device Driver.
Programming Languages and Paradigms Object-Oriented Programming.
Modular Programming Chapter Value and Reference Parameters t Function declaration: void computesumave(float num1, float num2, float& sum, float&
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 15: Linked data structures.
Working with Strings Lecture 2 Hartmut Kaiser
SIMULATED UNIX FILE SYSTEM Implementation in C Tarek Youssef Bipanjit Sihra.
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
1 MT258 Computer Programming and Problem Solving Unit 7.
Chapter 0.2 – Pointers and Memory. Type Specifiers  const  may be initialised but not used in any subsequent assignment  common and useful  volatile.
CS 590 Programming Environments with UNIX. Computer Lab Account Course Homepage
CSE 451 – Operating Systems Section, Autumn 2003 TAs: Mike Swift Adrienne Noble
Pointers OVERVIEW.
1 CSE 451 Section 2: Interrupts, Syscalls, Virtual Machines, and Project 1.
Nachos Project 4 Lecturer: Hao-Hua Chu TA: Chun-Po Wang (Artoo) Date: 2008/10/25.
Memory Management Issues, Solutions, and Examples.
Pointers in C++. 7a-2 Pointers "pointer" is a basic type like int or double value of a pointer variable contains the location, or address in memory, of.
Hashing Sections 10.2 – 10.3 CS 302 Dr. George Bebis.
Can’t provide fast insertion/removal and fast lookup at the same time Vectors, Linked Lists, Stack, Queues, Deques 4 Data Structures - CSCI 102 Copyright.
CSE 451: Operating Systems Section 1. Why are you here?  Because you want to work for Microsoft and hack on the Windows kernel? 3/29/  Because.
Agenda Attack Lab C Exercises C Conventions C Debugging
Hash Tables - Motivation
Hashing - 2 Designing Hash Tables Sections 5.3, 5.4, 5.4, 5.6.
CSE 451: Operating Systems Section 3: Project 0 recap, Project 1.
Chapter 3 Top-Down Design with Functions Part II J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National.
COSC 2007 Data Structures II Chapter 13 Advanced Implementation of Tables IV.
Operating Systems Process Creation
Generic lists Vassilis Athitsos. Problems With Textbook Interface? Suppose that we fix the first problem, and we can have multiple stacks. Can we have.
Chapter 13 : Symbol Management in Linking
(c) , University of Washington18a-1 CSC 143 Java Searching and Recursion N&H Chapters 13, 17.
Assignment 2: A Simple Address Book Andy Wang Data Structures, Algorithms, and Generic Programming.
Chapter 5 Linked List by Before you learn Linked List 3 rd level of Data Structures Intermediate Level of Understanding for C++ Please.
COP 3275 – Character Strings Instructor: Diego Rivera-Gutierrez.
Abstract Data Types and Stacks CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1.
CSE 332: C++ template examples Today: Using Class and Function Templates Two examples –Function template for printing different types –Class template for.
CSE 332: C++ STL iterators What is an Iterator? An iterator must be able to do 2 main things –Point to the start of a range of elements (in a container)
Unit 4: Processes, Threads & Deadlocks June 2012 Kaplan University 1.
MORE POINTERS Plus: Memory Allocation Heap versus Stack.
1 CSE 451 Section 2: Processes, the shell, and system calls.
CSE 451 Section 1 C Refresher (or introduction?) Project 0.
Defining Data Types in C++ Part 2: classes. Quick review of OOP Object: combination of: –data structures (describe object attributes) –functions (describe.
1 Ugly Realities The Dark Side of C++ Chapter 12.
CSE 451 Section #3 Project 0 Recap Project 1 Overview
Homework Notes from Sean
Secure Coding Rules for C++ Copyright © 2016 Curt Hill
Classes C++ representation of an object
CSE 451 Section 4 Project 1 Notes Looking ahead: Project 2.
Abstract Data Types and Stacks
Working with Strings Lecture 2 Hartmut Kaiser
Programmazione I a.a. 2017/2018.
The Bag and Sequence Classes with Linked Lists
Data Structures and Algorithms
Working with Strings Lecture 2 Hartmut Kaiser
Data Structures and Algorithms
CS5123 Software Validation and Quality Assurance
Classes C++ representation of an object
Presentation transcript:

CSE 451: Operating Systems Section 3 Project 0 recap, Project 1

Andrew Tanenbaum talk 10/14/102

Andrew Tanenbaum talk  Microkernels  Tanenbaum-Torvalds debate: pa.html pa.html  Software bloat  Is software really getting slower faster than hardware is getting faster? 10/14/103

Project 0 recap 10/14/104

Project 0: queue problems  Must check for empty queues before reversing or sorting  Should test on several queues  Short, long  Randomized order 10/14/105

Project 0: common problem #1  Linear probing misunderstandings  Must mark cells as vacated (different than free)  Consider hash table size of 10  Insert key1 -> hash = 5 ; Insert key2 -> hash = 15  Occupy positions 5 & 6  Delete key1  Lookup key2: 5 is empty but need to look at 6 also 10/14/106

Project 0: common problem #2  Properly handling set_hash_function()  Consider the following sequence:  Insert key1 -> hash = 5 under hash function a  Set hash function to b such that key1 -> hash = 6 under hash function b  Look up key1, turns out to be empty! 10/14/107

Project 0: common problem #2  Solutions?  Rehash  Prevent user from changing hash function if hash table is non-empty 10/14/108

Project 0: other problems  Resizing hash table  Using int or char as key type instead of general type (void *)  Memory leaks 10/14/109

Coding style 10/14/1010

Coding style  Write comments for tricky implementation sections:  Bad comment: somePtr = NULL; // Set somePtr to NULL  Good comment: somePtr = NULL; // Always reset the // pointer to NULL // after the shared // memory it points to // has been freed 10/14/1011

Coding style  Always use header guards: #ifndef _HASH_TABLE_H #define _HASH_TABLE_H // header file code here... #endif /* _HASH_TABLE_H */ 10/14/1012

Coding style  Be consistent with your naming  Functions: pick a style and stick to it  set_hash_function() style is ok  SetHashFunction() style also ok  End typenames in _t typedef foo_struct * foo_t;  Choose reasonable variable names int n_comp_conns; // BAD int num_completed_connections; // GOOD 10/14/1013

Coding style  Properly indent nested blocks  man 1 indent  Let your text editor do it for you! 10/14/1014

Coding style  Describe the interface when declaring functions in.h files  What does it do?  What assumptions does it make about its arguments?  What does it return?  How does it indicate an error condition? 10/14/1015

Memory management void do_stuff(char *buf, int len) {... free(buf); } int main() { char *mybuf = (char *)malloc(LEN*sizeof(char)); do_stuff(mybuf, LEN);... free(mybuf); // Double free: undefined // behavior! } 10/14/1016

Memory management  Always be explicit about who owns memory  If a function allocates some memory that the caller must free, say so!  If a function frees some memory that the caller should no longer use, say so!  Define pairs of allocate and free functions  Ideally, whoever calls allocate function also calls free function; if not, carefully consider usage 10/14/1017

Advanced memory mgmt.  What if multiple processes or threads are accessing the same structure in memory?  When can we free?  Reference counting  How does memory management within the kernel differ?  Slab allocator [Bonwick ’94] 10/14/1018

Project 1 10/14/1019

Project 1  Due Monday at 11:59pm!  Include all group members & group letter in write-up  Follow same turnin instructions again  Only one team member needs to run turnin 10/14/1020

Project 1 turnin  Preserve directories when submitting changed files  When we extract your changed files, they should go to the right directory, so it is unambiguous which file you changed  This is easy to do with tar command  Writeup requires a list of modified files (#3): please use full path name 10/14/1021

Project 1 notes  Special functions should be used to copy data between user space and kernel  Why?  access_ok(), copy_from_user(), copy_to_user(): look for example usage in kernel  Definition, gory details: arch/i386/lib/usercopy.c 10/14/1022

Project 1 notes  Where does printk() output go?  Possibly to console  include/linux/kernel.h: defines KERN_XYZ log levels  dmesg command  /var/log/messages 10/14/1023

Project 1 tips  Re-read the project description for hints  Read the man pages!  Navigating Linux kernel code: see Section 2  Get started!! 10/14/1024

Don’t forget  Steve Ballmer: CEO, Microsoft  Atrium, 3:30 today 10/14/1025

10/14/1026