minix/kernel/system/do_sprofile.c
Tomas Hruby 728f0f0c49 Removal of the system task
* Userspace change to use the new kernel calls

	- _taskcall(SYSTASK...) changed to _kernel_call(...)

	- int 32 reused for the kernel calls

	- _do_kernel_call() to make the trap to kernel

	- kernel_call() to make the actuall kernel call from C using
	  _do_kernel_call()

	- unlike ipc call the kernel call always succeeds as kernel is
	  always available, however, kernel may return an error

* Kernel side implementation of kernel calls

	- the SYSTEm task does not run, only the proc table entry is
	  preserved

	- every data_copy(SYSTEM is no data_copy(KERNEL

	- "locking" is an empty operation now as everything runs in
	  kernel

	- sys_task() is replaced by kernel_call() which copies the
	  message into kernel, dispatches the call to its handler and
	  finishes by either copying the results back to userspace (if
	  need be) or by suspending the process because of VM

	- suspended processes are later made runnable once the memory
	  issue is resolved, picked up by the scheduler and only at
	  this time the call is resumed (in fact restarted) which does
	  not need to copy the message from userspace as the message
	  is already saved in the process structure.

	- no ned for the vmrestart queue, the scheduler will restart
	  the system calls

	- no special case in do_vmctl(), all requests remove the
	  RTS_VMREQUEST flag
2010-02-09 15:20:09 +00:00

93 lines
2.3 KiB
C

/* The kernel call that is implemented in this file:
* m_type: SYS_SPROFILE
*
* The parameters for this kernel call are:
* m7_i1: PROF_ACTION (start/stop profiling)
* m7_i2: PROF_MEM_SIZE (available memory for data)
* m7_i3: PROF_FREQ (requested sample frequency)
* m7_i4: PROF_ENDPT (endpoint of caller)
* m7_p1: PROF_CTL_PTR (location of info struct)
* m7_p2: PROF_MEM_PTR (location of memory for data)
*
* Changes:
* 14 Aug, 2006 Created (Rogier Meurs)
*/
#include "../system.h"
#if SPROFILE
/* user address to write info struct */
PRIVATE vir_bytes sprof_info_addr_vir;
/*===========================================================================*
* do_sprofile *
*===========================================================================*/
PUBLIC int do_sprofile(struct proc * caller, message * m_ptr)
{
int proc_nr;
switch(m_ptr->PROF_ACTION) {
case PROF_START:
/* Starting profiling.
*
* Check if profiling is not already running. Calculate physical
* addresses of user pointers. Reset counters. Start CMOS timer.
* Turn on profiling.
*/
if (sprofiling) {
kprintf("SYSTEM: start s-profiling: already started\n");
return EBUSY;
}
/* Test endpoint number. */
if(!isokendpt(m_ptr->PROF_ENDPT, &proc_nr))
return EINVAL;
/* Set parameters for statistical profiler. */
sprof_ep = m_ptr->PROF_ENDPT;
sprof_info_addr_vir = (vir_bytes) m_ptr->PROF_CTL_PTR;
sprof_data_addr_vir = (vir_bytes) m_ptr->PROF_MEM_PTR;
sprof_info.mem_used = 0;
sprof_info.total_samples = 0;
sprof_info.idle_samples = 0;
sprof_info.system_samples = 0;
sprof_info.user_samples = 0;
sprof_mem_size = m_ptr->PROF_MEM_SIZE;
init_profile_clock(m_ptr->PROF_FREQ);
sprofiling = 1;
return OK;
case PROF_STOP:
/* Stopping profiling.
*
* Check if profiling is indeed running. Turn off profiling.
* Stop CMOS timer. Copy info struct to user process.
*/
if (!sprofiling) {
kprintf("SYSTEM: stop s-profiling: not started\n");
return EBUSY;
}
sprofiling = 0;
stop_profile_clock();
data_copy(KERNEL, (vir_bytes) &sprof_info,
sprof_ep, sprof_info_addr_vir, sizeof(sprof_info));
return OK;
default:
return EINVAL;
}
}
#endif /* SPROFILE */