Mercurial > hg > Game > Cerium
changeset 874:188e8bc16aca draft
new hash function
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 04 Jul 2010 19:17:10 +0900 |
parents | c50f39fbb6ca |
children | 9b7671710cea |
files | TaskManager/kernel/memory/MemHash.cc TaskManager/kernel/memory/MemHash.h TaskManager/kernel/schedule/Scheduler.cc example/get_segment/spe/Hello1.cc |
diffstat | 4 files changed, 26 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/kernel/memory/MemHash.cc Sun Jul 04 19:01:24 2010 +0900 +++ b/TaskManager/kernel/memory/MemHash.cc Sun Jul 04 19:17:10 2010 +0900 @@ -3,6 +3,28 @@ #include <stdlib.h> #include "MemHash.h" +unsigned int +MemHash::hash(memaddr data0) +{ + unsigned long data = (unsigned long)data0; +#if ABIBIT>32 + register int i_PeRlHaSh = 8; +#else + register int i_PeRlHaSh = 4; +#endif + register uint32 hash_PeRlHaSh = 0; + while (i_PeRlHaSh--) { + hash_PeRlHaSh += data & 0xff; + hash_PeRlHaSh += (hash_PeRlHaSh << 10); + hash_PeRlHaSh ^= (hash_PeRlHaSh >> 6); + data >>= 8; + } + hash_PeRlHaSh += (hash_PeRlHaSh << 3); + hash_PeRlHaSh ^= (hash_PeRlHaSh >> 11); + return (hash_PeRlHaSh + (hash_PeRlHaSh << 15)); +} + +#if 0 static unsigned short PRIME[8] = { 0x002, 0x065, 0x0c7, 0x133, 0x191, 0x1f3, 0x259, 0x2bd, }; @@ -24,6 +46,7 @@ return value % hashSize; } +#endif MemHash::MemHash() {
--- a/TaskManager/kernel/memory/MemHash.h Sun Jul 04 19:01:24 2010 +0900 +++ b/TaskManager/kernel/memory/MemHash.h Sun Jul 04 19:17:10 2010 +0900 @@ -12,7 +12,7 @@ public: void clear(void); - int hash(memaddr data); + unsigned int hash(memaddr data); int put(memaddr addr, MemorySegmentPtr ms); MemorySegmentPtr get(memaddr addr); void remove(memaddr addr);
--- a/TaskManager/kernel/schedule/Scheduler.cc Sun Jul 04 19:01:24 2010 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.cc Sun Jul 04 19:17:10 2010 +0900 @@ -228,7 +228,7 @@ (char*)task_list[task_id].segment->data + task_list[task_id].entry_offset); task_list[task_id].run = run; -#if 1 +#if 0 m->printf("loadng task id %d at 0x%x entry 0x%x location 0x%x\n",task_id, (unsigned int)(task_list[task_id].segment->data ), (unsigned int)(
--- a/example/get_segment/spe/Hello1.cc Sun Jul 04 19:01:24 2010 +0900 +++ b/example/get_segment/spe/Hello1.cc Sun Jul 04 19:17:10 2010 +0900 @@ -29,7 +29,7 @@ "1:" : "=r" (pc)); - char *fmt = "char [%0x] offset [%0x]\n"; + char *fmt = "char [%0x] offset [%0x] 2\n"; int offset = rel_offset(); //smanager->fprintf(smanager->stderr_,fmt+offset, fmt, offset);