Ah soo. It appears that when taking a float and making it an int it rounds down. So when I set my detect_thread_ratio values at .1, .2, .3, .4, .5, .6, .7, .8, .9, I will get 4, 9, 14, 19, 24, 28, 33, 38, and 43 respectively.<div>
</div><div>Do I get a star?</div><div><br></div><div>Gene<br><div><br><div class="gmail_quote">On Fri, Aug 12, 2011 at 4:05 PM, Will Metcalf <span dir="ltr"><<a href="mailto:william.metcalf@gmail.com">william.metcalf@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I did leave out this piece...<br>
<br>
src/runmodes.h:extern float threading_detect_ratio;<br>
<br>
It is key...<br>
<br>
mmmmm grasshopper the answer lies in the code below...<br>
<br>
gcc -o makin-stuff makin-stuff.c<br>
./makin-stuff<br>
<br>
--------snip---------------<br>
#include <stdio.h><br>
<br>
main(){<br>
int foo = 48;<br>
float bar = 0.2;<br>
int blat;<br>
<br>
blat = foo * bar;<br>
printf("where did my remainder go? %i\n", blat);<br>
<br>
printf("how many do we make?\n");<br>
int i;<br>
for (i = 0; i < blat; i++) {<br>
printf("%i\n", i +1);<br>
}<br>
return 0;<br>
<div><div></div><div class="h5">}<br>
<br>
<br>
<br>
On Fri, Aug 12, 2011 at 5:10 PM, Gene Albin <<a href="mailto:gene.albin@gmail.com">gene.albin@gmail.com</a>> wrote:<br>
> Ok, so if I'm reading that right (and it's like reading<br>
> ancient hieroglyphics to me!) it looks like first we will never have less<br>
> than 1 thread, and second we are working with integers so no decimals. If<br>
> that is the case, then does the 'int' function round decimals to the nearest<br>
> integer or does it round all down? I don't see anything there forcing it to<br>
> round down so I'd assume it rounds to the nearest.<br>
> So my 'homework' answer would be that it uses integers and rounds to the<br>
> nearest integer > 0.<br>
> How'd I do, teach?<br>
> Gene<br>
> On Fri, Aug 12, 2011 at 2:59 PM, Will Metcalf <<a href="mailto:william.metcalf@gmail.com">william.metcalf@gmail.com</a>><br>
> wrote:<br>
>><br>
>> Since this all sounds a bit like a homework assignment you tell me :D?<br>
>><br>
>> * threads we're not creating the most on CPU0. */<br>
>> if (ncpus > 0)<br>
>> cpu = 1;<br>
>><br>
>> /* always create at least one thread */<br>
>> int thread_max = TmThreadGetNbThreads(DETECT_CPU_SET);<br>
>> if (thread_max == 0)<br>
>> thread_max = ncpus * threading_detect_ratio;<br>
>> if (thread_max < 1)<br>
>> thread_max = 1;<br>
>><br>
>> int thread;<br>
>> for (thread = 0; thread < thread_max; thread++) {<br>
>> snprintf(tname, sizeof(tname), "Detect%"PRIu16, thread+1);<br>
>><br>
>> char *thread_name = SCStrdup(tname);<br>
>> SCLogDebug("Assigning %s affinity to cpu %u", thread_name, cpu);<br>
>><br>
>> ThreadVars *tv_detect_ncpu =<br>
>> TmThreadCreatePacketHandler(thread_name,<br>
>> "stream-queue1", "simple",<br>
>> "alert-queue1", "simple",<br>
>> "1slot");<br>
>> if (tv_detect_ncpu == NULL) {<br>
>> printf("ERROR: TmThreadsCreate failed\n");<br>
>> exit(EXIT_FAILURE);<br>
>> }<br>
>> tm_module = TmModuleGetByName("Detect");<br>
>> if (tm_module == NULL) {<br>
>> printf("ERROR: TmModuleGetByName Detect failed\n");<br>
>> exit(EXIT_FAILURE);<br>
>> }<br>
>> Tm1SlotSetFunc(tv_detect_ncpu, tm_module, (void *)de_ctx);<br>
>><br>
>> TmThreadSetCPU(tv_detect_ncpu, DETECT_CPU_SET);<br>
>><br>
>> char *thread_group_name = SCStrdup("Detect");<br>
>> if (thread_group_name == NULL) {<br>
>> printf("Error allocating memory\n");<br>
>> exit(EXIT_FAILURE);<br>
>> }<br>
>> tv_detect_ncpu->thread_group_name = thread_group_name;<br>
>><br>
>> if (TmThreadSpawn(tv_detect_ncpu) != TM_ECODE_OK) {<br>
>> printf("ERROR: TmThreadSpawn failed\n");<br>
>> exit(EXIT_FAILURE);<br>
>> }<br>
>><br>
>> if ((cpu + 1) == ncpus)<br>
>> cpu = 0;<br>
>> else<br>
>> cpu++;<br>
>> }<br>
>><br>
>><br>
>> On Fri, Aug 12, 2011 at 4:38 PM, Gene Albin <<a href="mailto:gene.albin@gmail.com">gene.albin@gmail.com</a>> wrote:<br>
>> > I understand that the detect_thread_ratio in the suricata.yaml file<br>
>> > determines the number of threads created by multiplying the ratio number<br>
>> > by<br>
>> > the number of CPU cores. What does Suricata do when the result is not<br>
>> > an<br>
>> > integer? For example .2*48=9.6. Is this rounded down to the lowest<br>
>> > integer? Does it create 9.6 threads? Does it round up?<br>
>> ><br>
>> > Thanks,<br>
>> > --<br>
>> > Gene Albin<br>
>> > <a href="mailto:gene.albin@gmail.com">gene.albin@gmail.com</a><br>
>> ><br>
>> ><br>
>> > _______________________________________________<br>
>> > Oisf-users mailing list<br>
>> > <a href="mailto:Oisf-users@openinfosecfoundation.org">Oisf-users@openinfosecfoundation.org</a><br>
>> > <a href="http://lists.openinfosecfoundation.org/mailman/listinfo/oisf-users" target="_blank">http://lists.openinfosecfoundation.org/mailman/listinfo/oisf-users</a><br>
>> ><br>
>> ><br>
><br>
><br>
><br>
> --<br>
> Gene Albin<br>
> <a href="mailto:gene.albin@gmail.com">gene.albin@gmail.com</a><br>
><br>
><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Gene Albin<br><a href="mailto:gene.albin@gmail.com" target="_blank">gene.albin@gmail.com</a><br><br>
</div></div>