[OSy] Preempce v kohlto

Nodir Yuldashev y_nodir at yahoo.com
Tue Jan 9 00:18:57 CET 2007


Hezky vecer,

vypada, ze tento kod dole zpusobuje to, ze thread
assignment_test se nepreplanuje. Teda v pocatku se to
preplanuje 2x, a pak uz nic.

To jsou jedine zmeny, ktere jsem udelal v main.c:


- pridal jsem na pocatek nejake definice

#define PROGRAM_BEGIN_ADDRESS 0x00000000
#define CODE_SEGMENT_SIZE (32*1024)
#define USER_STACK_SIZE  (128*1024)
#define EXT_DEVICE_BEGIN 0x90000000


- zmenil jsem assignment_test takto (take v main.c):

void assignment_test(void *data) {

	int retVal;
	
	uint8_t * src;
	uint8_t * dest;
	size_t	i;
	
	void *where = (void *)PROGRAM_BEGIN_ADDRESS;

	puts("Allocating virtual memory for process
code...");

	retVal = vmalloc(&where, CODE_SEGMENT_SIZE,
(VF_VA_USER << VF_VA_SHIFT));
	
	if( retVal != EOK) {
		printk("idle_thread2: vmalloc() returned
error!!!!\n");
		return;
	}
	
	for (;;) {

		puts("Copying program2 into code segment...\n");
	
		src = (uint8_t *)EXT_DEVICE_BEGIN;
		dest = (uint8_t *)PROGRAM_BEGIN_ADDRESS;
	
		for(i = 0; i < (CODE_SEGMENT_SIZE /
sizeof(uint8_t)); i++) {
//			dprintk("Thread2: i=%d\n",i);
			dest[i] = src[i];
		}

		puts("Copying program2 finished...");

		printk("Sem thread 2...\n");

//		thread_yield();

	}
}


- To je zmena fci idle_thread v idle_thread.c

void idle_thread(void *data)
{
	for (;;) {
		printk("Tohle je idle_thread\n");
		thread_yield();
	}
}


Navic tu nevadi, jestli na adrese EXT_DEVICE_BEGIN je
loadovana binarka nebo ne (pomoci msim.conf).
Nejzajimavejsi je, ze staci odkomentovat v fci
assignment_test radek s "dprintk..." v for-cyklu, a to
vsechno zacina fungovat tak jak to ma. Sice
odkomentovanim radku "thread_yield()" se to spravi,
nemelo by to byt problem i bez toho.
Co byste poradili?

Diky za odpovedi,
NY.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the NSWI004 mailing list