Linux Linked List - It scales up very well to very large...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Linux Linked List struct list_head { struct list_head *next, *prev; }; #define LIST_HEAD(name) \ struct list_head name = LIST_HEAD_INIT(name) #define INIT_LIST_HEAD(ptr) do { \ (ptr)->next = (ptr); (ptr)->prev = (ptr); \ } while (0) #define list_entry(ptr, type, member) \ ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
Background image of page 1

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

View Full DocumentRight Arrow Icon
Linux Linked List Notice that the the macro: #define list_entry(ptr, type, member) \ ((type *)((char *)(ptr)-(unsigned long) Obtains the beginning of the struct in the list given the list entry field in the struct This is very versatile since it allows a struct to belong to more than one list. Here is an example of the list of open files.
Background image of page 2
Linked List Iteration Example fs/file_table.c:fs_may_remount_ro()): struct super_block { ... struct list_head s_files; ... } *sb = &some_super_block; struct file { ... struct list_head f_list; ... } *file;
Background image of page 3

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

View Full DocumentRight Arrow Icon
The Linux 2.6 Scheduler
Background image of page 4
Background image of page 5

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

View Full DocumentRight Arrow Icon
Background image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: It scales up very well to very large number of threads. It is O(1) with the number of processes. It was motivated by the fact the applications in Java Virtual Machines (JVMs) you could have thousands of threads so a O(n) scheduler was slow. The Linux 2.6 Scheduler There are 140 priority lists The top 100 priority lists are reserved for real-time tasks. The last 40 are used for user tasks. There are two sets of queues: Expired runqueue Active runqueue The scheduler chooses tasks from the runqueue Tasks that have their CPU time expired have their priority recomputed and are moved to the expired-runtime After there are no tasks in the runqueue, it swaps the expired runqueue and the active runqueue. The Linux 2.6 Scheduler Expired runqueue Priority 1 Priority 2 Priority 100 Priority 140 Active runqueue Priority 1 Priority 2 Priority 100 Priority 140...
View Full Document

This note was uploaded on 01/30/2012 for the course CS 354 taught by Professor Staff during the Fall '08 term at Purdue University-West Lafayette.

Page1 / 6

Linux Linked List - It scales up very well to very large...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online