sys/src/sched.c File Reference

Scheduling - TODO still more doc. More...

#include <system_data_cells.h>
#include <dyndef.h>
#include <phddef.h>
#include <linux/config.h>
#include <linux/mm.h>
#include <linux/init.h>
#include <linux/smp_lock.h>
#include <linux/nmi.h>
#include <linux/interrupt.h>
#include <linux/kernel_stat.h>
#include <linux/completion.h>
#include <linux/prefetch.h>
#include <linux/compiler.h>
#include <asm/uaccess.h>
#include <asm/mmu_context.h>
#include <sysgen.h>
#include <ipldef.h>
#include <ipl.h>
#include <statedef.h>
#include <queue.h>
#include <system_service_setup.h>
#include <internals.h>
#include <exe_routines.h>
#include <sch_routines.h>
#include <misc_routines.h>
#include <cpbdef.h>
#include <rsndef.h>

Go to the source code of this file.

Defines

#define DEBUG_SCHED
#define TICK_SCALE(x)   ((x) >> 2)
#define NICE_TO_TICKS(nice)   (TICK_SCALE(20-(nice))+1)
#define idle_task(cpu)   (&init_task)
#define can_schedule(p, cpu)   (1)
#define SLEEP_ON_VAR
#define SLEEP_ON_HEAD
#define SLEEP_ON_TAIL

Functions

void timer_bh (void)
void tqueue_bh (void)
void immediate_bh (void)
void mem_use (void)
 mycheckaddr (unsigned int ctl)
 check content ok
int numproc (void)
void printcom (void)
void printcom2 (void)
void scheduling_functions_start_here (void)
int task_on_comqueue (struct _pcb *p)
 is the task on comqueue?
int fastcall wake_up_process (struct task_struct *p)
signed long fastcall schedule_timeout (signed long timeout)
asmlinkage void sch_sched (int)
asmlinkage void sch_resched (void)
 rescheduling - see 5.2 12.6.4
asmlinkage void schedule (void)
asmlinkage void sch_sched (int from_sch $resched)
void fastcall __wake_up (wait_queue_head_t *q, unsigned int mode, int nr)
void fastcall __wake_up_sync (wait_queue_head_t *q, unsigned int mode, int nr)
void fastcall complete (struct completion *x)
void fastcall wait_for_completion (struct completion *x)
void fastcall interruptible_sleep_on (wait_queue_head_t *q)
long fastcall interruptible_sleep_on_timeout (wait_queue_head_t *q, long timeout)
void fastcall sleep_on (wait_queue_head_t *q)
long fastcall sleep_on_timeout (wait_queue_head_t *q, long timeout)
void scheduling_functions_end_here (void)
asmlinkage long sys_nice (int increment)
struct task_struct * find_process_by_pid (pid_t pid)
asmlinkage long sys_sched_setscheduler (pid_t pid, int policy, struct sched_param *param)
asmlinkage long sys_sched_setparam (pid_t pid, struct sched_param *param)
asmlinkage long sys_sched_getscheduler (pid_t pid)
asmlinkage long sys_sched_getparam (pid_t pid, struct sched_param *param)
asmlinkage long sys_sched_yield (void)
asmlinkage long sys_sched_get_priority_max (int policy)
asmlinkage long sys_sched_get_priority_min (int policy)
asmlinkage long sys_sched_rr_get_interval (pid_t pid, struct timespec *interval)
char * render_sigset_t (sigset_t *set, char *buffer)
void show_state (void)
void reparent_to_init (void)
void daemonize (void)
void __init init_idle (void)
void init_timervecs (void)
void __init sched_init (void)

Variables

int done_init_idle = 0
unsigned securebits = SECUREBITS_DEFAULT
int mydebug4 = 0
int mydebug5 = 0
int mydebug6 = 1
struct task_struct * init_tasks [NR_CPUS] = {&init_task, }
spinlock_t runqueue_lock __cacheline_aligned = SPIN_LOCK_UNLOCKED
struct kernel_stat kstat
struct task_struct * child_reaper
int fix_init_thread
int countme = 500
int mydebug = 0
int mydebug2 = 0
int mycount = 0
unsigned long wait_init_idle
struct _phd system_phd
unsigned long pcbvec []
unsigned long seqvec []


Detailed Description

Scheduling - TODO still more doc.

Author:
Roar Thronęs

Definition in file sched.c.


Define Documentation

#define can_schedule ( p,
cpu   )     (1)

Definition at line 295 of file sched.c.

#define DEBUG_SCHED

Definition at line 73 of file sched.c.

#define idle_task ( cpu   )     (&init_task)

Definition at line 294 of file sched.c.

Referenced by sch_resched(), sch_sched(), and sys_sched_yield().

#define NICE_TO_TICKS ( nice   )     (TICK_SCALE(20-(nice))+1)

Definition at line 259 of file sched.c.

Referenced by sys_sched_rr_get_interval().

#define SLEEP_ON_HEAD

Value:

wq_write_lock_irqsave(&q->lock,flags);          \
        __add_wait_queue(q, &wait);                     \
        wq_write_unlock(&q->lock);

Definition at line 1241 of file sched.c.

Referenced by interruptible_sleep_on(), interruptible_sleep_on_timeout(), sleep_on(), and sleep_on_timeout().

#define SLEEP_ON_TAIL

Value:

wq_write_lock_irq(&q->lock);                            \
        __remove_wait_queue(q, &wait);                          \
        wq_write_unlock_irqrestore(&q->lock,flags);

Definition at line 1246 of file sched.c.

Referenced by interruptible_sleep_on(), interruptible_sleep_on_timeout(), sleep_on(), and sleep_on_timeout().

#define SLEEP_ON_VAR

Value:

unsigned long flags;                    \
        wait_queue_t wait;                      \
        init_waitqueue_entry(&wait, current);

Definition at line 1236 of file sched.c.

Referenced by interruptible_sleep_on(), interruptible_sleep_on_timeout(), sleep_on(), and sleep_on_timeout().

#define TICK_SCALE (  )     ((x) >> 2)

Definition at line 248 of file sched.c.


Function Documentation

void fastcall __wake_up ( wait_queue_head_t *  q,
unsigned int  mode,
int  nr 
)

Definition at line 1179 of file sched.c.

void fastcall __wake_up_sync ( wait_queue_head_t *  q,
unsigned int  mode,
int  nr 
)

Definition at line 1191 of file sched.c.

void fastcall complete ( struct completion *  x  ) 

Definition at line 1203 of file sched.c.

void daemonize ( void   ) 

Definition at line 1742 of file sched.c.

struct task_struct* find_process_by_pid ( pid_t  pid  )  [read]

void immediate_bh ( void   ) 

Referenced by sched_init().

void __init init_idle ( void   ) 

Definition at line 1773 of file sched.c.

References _pcb, done_init_idle, smp_gl_cpu_data, and system_phd.

void init_timervecs ( void   ) 

Referenced by sched_init().

void fastcall interruptible_sleep_on ( wait_queue_head_t *  q  ) 

Definition at line 1251 of file sched.c.

References schedule(), SLEEP_ON_HEAD, SLEEP_ON_TAIL, and SLEEP_ON_VAR.

long fastcall interruptible_sleep_on_timeout ( wait_queue_head_t *  q,
long  timeout 
)

Definition at line 1263 of file sched.c.

References schedule_timeout(), SLEEP_ON_HEAD, SLEEP_ON_TAIL, and SLEEP_ON_VAR.

void mem_use ( void   ) 

mycheckaddr ( unsigned int  ctl  ) 

check content ok

Definition at line 102 of file sched.c.

References _pcb, ctl_gl_pcb, sch_aq_comh, sch_aq_comt, and sch_gl_comqs.

Referenced by sch_chsep(), sch_chsep2(), sch_resched(), sch_rse(), and sch_sched().

int numproc ( void   ) 

Definition at line 172 of file sched.c.

References _pcb, and sch_aq_comh.

Referenced by sch_resched(), and sch_sched().

void printcom ( void   ) 

Definition at line 192 of file sched.c.

References _pcb, sch_aq_comh, and sch_gl_comqs.

Referenced by sch_resched(), and sch_sched().

void printcom2 ( void   ) 

Definition at line 212 of file sched.c.

References _pcb, sch_aq_comh, sch_aq_comt, and sch_gl_comqs.

char* render_sigset_t ( sigset_t *  set,
char *  buffer 
)

Definition at line 1648 of file sched.c.

void reparent_to_init ( void   ) 

reparent_to_init() - Reparent the calling kernel thread to the init task.

If a kernel thread is launched as a result of a system call, or if it ever exits, it should generally reparent itself to init so that it is correctly cleaned up on exit.

The various task state such as scheduling policy and priority may have been inherited fro a user process, so we reset them to sane values here.

NOTE that reparent_to_init() gives the caller full capabilities.

Definition at line 1701 of file sched.c.

References child_reaper, and DEFPRI.

asmlinkage void sch_resched ( void   ) 

rescheduling - see 5.2 12.6.4

spinlock sched and set ipl

get current pcb and priority

clear bit in cpu_priority table

if no process with this pri on any cpu, clear bit in active_priority table

now some if's remaining from linux - TODO: check if still needed

set pri bit in comqs

set state of cur pcb to COM

insert pcb at tail of comqueue

linux leftover

clear idle_cpus to signal all idle cpus to try to reschedule

go some intro sch_sched

Definition at line 622 of file sched.c.

References _pcb, _cpu::cpu_b_cur_pri, _cpu::cpu_l_curpcb, idle_task, IPL__RESCHED, IPL__SCHED, mycheckaddr(), numproc(), printcom(), sch_al_cpu_priority, sch_aq_comh, sch_aq_comt, sch_gl_active_priority, sch_gl_comqs, sch_gl_idle_cpus, sch_sched(), smp_gl_cpu_data, SPIN_SCHED, and task_on_comqueue().

asmlinkage void sch_sched ( int from_sch $  resched  ) 

clear cpu_priority for current pri bit - TODO: where did this come from?

skip if ... TODO: from where?

clear active_priority for current pri bit - TODO: where did this come from?

now 4 linux leftovers

reset cpu affinity TODO: from where?

find highest pri comqueue

if none found, idle

set bit in idle_cpus

store null pcb and -1 pri: MISSING check why

necessary idle_task line from linux

if pcb in queue

get new pcb from selected comqueue

zero next pcb queue header TODO: check if still needed

linux pcb count leftover

if last in queue clear comqs bit

test process capabilities

if the capabilities match, store new pcb in per-cpu db

change new pcb to CUR state

store cpu id in pcb

modify new pcb pri

copy new pri in cpu pri db

clear idle_cpus mask TODO: check setting cpuid_mask

set bit it cpu_priority table to cpuid_mask

set bit in active_priority

this if is a linux leftover

sets pcb cpu_id again TODO: not needed?

spinunlock

linux count line

from here, prepare_to_switch() and switch_to() are from linux, due to missing LDPCTX and SVPCTX etc

need to set astlvl

Definition at line 765 of file sched.c.

References _pcb, _cpu::cpu_b_cur_pri, _cpu::cpu_b_ipl, _cpu::cpu_l_curpcb, idle_task, IPL__RESCHED, IPL__SCHED, kstat, mycheckaddr(), mydebug4, mydebug5, mydebug6, numproc(), printcom(), qhead_init(), sch_al_cpu_priority, sch_aq_comh, sch_gl_active_priority, sch_gl_capability_sequence, sch_gl_comqs, sch_gl_idle_cpus, sch_gl_resmask, sch_gq_mwait, smp_gl_cpu_data, SPIN_SCHED, and _spl::spl_l_spinlock.

asmlinkage void sch_sched ( int   ) 

void __init sched_init ( void   ) 

asmlinkage void schedule ( void   ) 

signed long fastcall schedule_timeout ( signed long  timeout  ) 

schedule_timeout - sleep until timeout : timeout value in jiffies

Make the current task sleep until jiffies have elapsed. The routine will return immediately unless the current task state has been set (see set_current_state()).

You can set the task state as follows -

TASK_UNINTERRUPTIBLE - at least jiffies are guaranteed to pass before the routine returns. The routine will return 0

TASK_INTERRUPTIBLE - the routine may return early if a signal is delivered to the current task. In this case the remaining time in jiffies will be returned, or 0 if the timer expired in time

The current task state is guaranteed to be TASK_RUNNING when this routine returns.

Specifying a value of MAX_SCHEDULE_TIMEOUT will schedule the CPU away without a bound on the timeout. In this case the return value will be MAX_SCHEDULE_TIMEOUT.

In all cases the return value is guaranteed to be non-negative.

Definition at line 556 of file sched.c.

References schedule().

Referenced by interruptible_sleep_on_timeout(), and sleep_on_timeout().

void scheduling_functions_end_here ( void   ) 

Definition at line 1303 of file sched.c.

void scheduling_functions_start_here ( void   ) 

Definition at line 299 of file sched.c.

void show_state ( void   ) 

Definition at line 1663 of file sched.c.

void fastcall sleep_on ( wait_queue_head_t *  q  ) 

Definition at line 1277 of file sched.c.

References schedule(), SLEEP_ON_HEAD, SLEEP_ON_TAIL, and SLEEP_ON_VAR.

long fastcall sleep_on_timeout ( wait_queue_head_t *  q,
long  timeout 
)

Definition at line 1289 of file sched.c.

References schedule_timeout(), SLEEP_ON_HEAD, SLEEP_ON_TAIL, and SLEEP_ON_VAR.

asmlinkage long sys_nice ( int  increment  ) 

Definition at line 1313 of file sched.c.

asmlinkage long sys_sched_get_priority_max ( int  policy  ) 

Definition at line 1545 of file sched.c.

References PCB_K_SCHED_FIFO, PCB_K_SCHED_OTHER, and PCB_K_SCHED_RR.

asmlinkage long sys_sched_get_priority_min ( int  policy  ) 

Definition at line 1561 of file sched.c.

References PCB_K_SCHED_FIFO, PCB_K_SCHED_OTHER, and PCB_K_SCHED_RR.

asmlinkage long sys_sched_getparam ( pid_t  pid,
struct sched_param *  param 
)

Definition at line 1465 of file sched.c.

References exe_epid_to_ipid(), and find_process_by_pid().

asmlinkage long sys_sched_getscheduler ( pid_t  pid  ) 

Definition at line 1442 of file sched.c.

References exe_epid_to_ipid(), and find_process_by_pid().

asmlinkage long sys_sched_rr_get_interval ( pid_t  pid,
struct timespec *  interval 
)

Definition at line 1576 of file sched.c.

References exe_epid_to_ipid(), find_process_by_pid(), and NICE_TO_TICKS.

asmlinkage long sys_sched_setparam ( pid_t  pid,
struct sched_param *  param 
)

Definition at line 1435 of file sched.c.

References exe_epid_to_ipid().

asmlinkage long sys_sched_setscheduler ( pid_t  pid,
int  policy,
struct sched_param *  param 
)

Definition at line 1427 of file sched.c.

References exe_epid_to_ipid().

asmlinkage long sys_sched_yield ( void   ) 

Definition at line 1499 of file sched.c.

References idle_task.

int task_on_comqueue ( struct _pcb *  p  ) 

is the task on comqueue?

Definition at line 405 of file sched.c.

References _pcb, and sch_aq_comh.

Referenced by sch_chsep(), sch_resched(), and sch_waitk().

void timer_bh ( void   ) 

Referenced by sched_init().

void tqueue_bh ( void   ) 

Referenced by sched_init().

void fastcall wait_for_completion ( struct completion *  x  ) 

Definition at line 1213 of file sched.c.

References schedule().

int fastcall wake_up_process ( struct task_struct *  p  )  [inline]

Definition at line 518 of file sched.c.


Variable Documentation

struct _spl SPIN_IOPOST __cacheline_aligned = SPIN_LOCK_UNLOCKED [read]

Definition at line 280 of file sched.c.

struct task_struct* child_reaper

Referenced by reparent_to_init().

int countme = 500

Definition at line 616 of file sched.c.

int done_init_idle = 0

Definition at line 84 of file sched.c.

Referenced by init_idle().

struct task_struct* init_tasks[NR_CPUS] = {&init_task, }

Definition at line 267 of file sched.c.

Referenced by exe_pscan_next_id().

struct kernel_stat kstat

Definition at line 283 of file sched.c.

Referenced by sch_sched(), vms_do_IRQ(), and vms_get_irq_list().

int mycount = 0

Definition at line 754 of file sched.c.

int mydebug = 0

Definition at line 752 of file sched.c.

int mydebug2 = 0

Definition at line 753 of file sched.c.

int mydebug4 = 0

Definition at line 94 of file sched.c.

Referenced by sch_sched().

int mydebug5 = 0

Definition at line 95 of file sched.c.

Referenced by sch_sched().

int mydebug6 = 1

Definition at line 96 of file sched.c.

Referenced by sch_sched().

unsigned long pcbvec[]

Definition at line 2019 of file system_data_cells.c.

unsigned securebits = SECUREBITS_DEFAULT

Definition at line 90 of file sched.c.

unsigned long seqvec[]

Definition at line 2020 of file system_data_cells.c.

struct _phd system_phd

Definition at line 2002 of file system_data_cells.c.

Referenced by init_idle(), and vms_init3().

unsigned long wait_init_idle


Generated on Fri Oct 9 10:26:01 2009 for FreeVMS by  doxygen 1.5.5