Commit Graph

648 Commits

Author SHA1 Message Date
Iván Briano 1277d5b855 Dead code bye bye
SVN revision: 53497
2010-10-16 21:32:08 +00:00
Cedric BAIL 94fb47d168 * ecore: improve and fix ecore_thread destruction.
SVN revision: 53411
2010-10-14 16:45:48 +00:00
Cedric BAIL 5ce901459c * ecore: don't leak pipe.
SVN revision: 53410
2010-10-14 16:45:17 +00:00
Cedric BAIL 25e84c7f3d * ecore: fix possible race. It also make ecore_thread_run
match ecore_thread_feedback_run better.

	NOTE: I know it breaks API/ABI compatibility for that call,
	but that's the only sane solution I could found.


SVN revision: 53370
2010-10-13 17:45:07 +00:00
Cedric BAIL 00c7021fcb * ecore: turn on and off eina threads support when needed.
SVN revision: 53364
2010-10-13 16:44:15 +00:00
Carsten Haitzler 031f1fecf5 and.. be safe! for funcs so they dont go closing things when they
already are.



SVN revision: 53324
2010-10-13 00:37:12 +00:00
Carsten Haitzler 5eeda40f55 if pipe handler deletes the pipe... be safe!
SVN revision: 53323
2010-10-13 00:35:09 +00:00
Cedric BAIL d2736c4d66 ecore: return more information on pipe_read error.
SVN revision: 53263
2010-10-11 13:27:03 +00:00
Gustavo Sverzut Barbieri 3a88bc8b71 log domains in lower-case only please.
let's make it a standard so we don't have to look at the code
everytime to figure out the name...



SVN revision: 53172
2010-10-07 22:31:46 +00:00
Eduardo de Barros Lima 2f1827d132 Ecore: No need to #define _GNU_SOURCE
SVN revision: 53162
2010-10-07 20:40:33 +00:00
Mike McCormack b34b4c2359 From: Mike McCormack <mj.mccormack@samsung.com>
Subject: ecore-glib integration patches

0001-Make-gmain-integration-work.path applies to the enlightenment SVN.

(in svn with some formatting fixes applied).



SVN revision: 53135
2010-10-07 07:23:26 +00:00
Lucas De Marchi 5c43c88f74 Fix signal accounting
copy&paste--

By: "Ulisses Furquim" <ulisses@profusion.mobi>


SVN revision: 53129
2010-10-07 00:33:51 +00:00
Cedric BAIL 6b5c401b1f * ecore: fix typo.
SVN revision: 53098
2010-10-06 13:01:35 +00:00
Cedric BAIL d617b8574d * ecore: refcount send and received notify to prevent leak on
ecore_thread_cancel.


SVN revision: 53096
2010-10-06 11:48:45 +00:00
Cedric BAIL 05262d2120 * ecore: remove thread from the correct list.
SVN revision: 53029
2010-10-04 15:24:34 +00:00
Vincent Torri 16263f52cc tab--
SVN revision: 52918
2010-09-30 06:09:20 +00:00
Lucas De Marchi 61a510d387 Fix clock_gettime detection in autotools
AC_CHECK_FUNCS checks for the existence of functions in the C standard
library, so we don't need it. Instead, we need to define
HAVE_CLOCK_GETTIME if the function was found inside the librt.

Moreover, in source file check if HAVE_CLOCK_GETTIME is defined rather
than of checking if it's 0.



SVN revision: 52863
2010-09-28 19:36:50 +00:00
Christopher Michael 1fe0153f77 Fix ecore to at least compile on systems that don't have clock_getting.
NB: Not sure if this is a correct fix or not, but at least svn is not
busted anymore.



SVN revision: 52831
2010-09-28 00:21:48 +00:00
Lucas De Marchi 162070b8f5 Respect namespace
_ecore_loop_time -> _ecore_time_loop_time



SVN revision: 52825
2010-09-27 22:35:55 +00:00
Lucas De Marchi d17de81175 Make ecore_time_get and friends use monotonic clock
Instead of relying on unix time, use a monotonic clock provided by
clock_gettime(). If a monotonic clock is not available, it will fallback
to CLOCK_REALTIME or unix time if neither is available.

The impact is that now it only makes sense to call ecore_time_get() or
ecore_time_loop_get() if the value retrieved is intended to be used as
relative to previous/posterior measurements. If an absolute value is
needed, the right function to call now is ecore_time_unix_get() which
will give the number of seconds since Jan 1st, 1970, 12:00AM.



SVN revision: 52824
2010-09-27 22:35:35 +00:00
Lucas De Marchi 85599b20eb Use eina_sched_prio_drop()
SVN revision: 52652
2010-09-23 20:39:40 +00:00
Vincent Torri 02ffe4765c Windows: too much noise in the console with animations
SVN revision: 52647
2010-09-23 18:44:48 +00:00
Cedric BAIL b462783cae * ecore: oops, forgot that change.
SVN revision: 52580
2010-09-22 11:09:44 +00:00
Cedric BAIL 8036a32918 * ecore: rename ecore_long_run to ecore_thread_feedback_run.
SVN revision: 52573
2010-09-22 09:47:55 +00:00
Mike Blumenkrantz f3a2858f37 remove unused variable
SVN revision: 52529
2010-09-21 02:16:40 +00:00
Mike Blumenkrantz 786e2bd7e4 ecore_main_fd_handler_active_get -> Eina_Bool
SVN revision: 52528
2010-09-21 02:06:41 +00:00
Mike Blumenkrantz 130f5bec81 doxy error fixes
SVN revision: 52512
2010-09-20 20:33:50 +00:00
Lucas De Marchi 71cba7da35 Fix typos
"he->the" where appropriate



SVN revision: 52493
2010-09-20 17:09:13 +00:00
Carsten Haitzler 773c57ea1a warning--
SVN revision: 52453
2010-09-19 03:09:09 +00:00
Carsten Haitzler 4081d86c6c better cleanup of poll fd's on shutdown
SVN revision: 52229
2010-09-14 00:53:57 +00:00
Lucas De Marchi 325e08065d Fix priority dropping
Lowering priority was wrong. Some bugs:

1) You don't lower the priority by setting the scheduler policy to some
   of the real-time ones (SCHED_RR or SCHER_FIFO). If you do so, you are
   actually increasing the priority of the workers and your main thread
   you be preempted and stalled until the workers complete their job.
   Fortunately this will only happen if your programming is running as
   root, as normal users (without CAP_SYS_NICE) are unable to set
   priority to real-time values.

2) setpriority() and getpriority() are not part of pthread and you can't
   use the id returned by pthread. Manpage explicitly says so on
   pthread_self(3):
   "The  thread ID returned by pthread_self() is not the same thing as the
       kernel thread ID returned by a call to gettid(2)."

   Since glibc does not have a gettid, here we are using
   syscall(SYS_gettid)

This patch was tested with the program below. Compile and run:
   $ gcc p_hello2.c -o p_hello2 -lpthread
   $ ./p_hello2 10

You'll see that the main thread remains with its priority and threads
created by the main thread change their own niceness.

#include <errno.h>
#include <pthread.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/resource.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <sys/types.h>

/* Lower priority of current thread.
 *
 * It's used by worker threads so they use up "bg cpu" as it was really intended
 * to work. If current thread is running with real-time priority, we decrease
 * our priority by 5. This is done in a portable way.  Otherwise we are
 * running with SCHED_OTHER policy and there's no portable way to set the nice
 * level on current thread. In Linux, it does work and it's the only one that is
 * implemented.
 */
static void
_ecore_thread_pri_drop(void)
{
   struct sched_param param;
   int pol, prio, ret;
   pid_t tid;
   pthread_t pthread_id;

   pthread_id = pthread_self();
   ret = pthread_getschedparam(pthread_id, &pol, &param);
   if (ret)
     {
        fprintf(stderr, "Unable to query sched parameters\n");
        return;
     }

   if (pol == SCHED_RR || pol == SCHED_FIFO)
     {
        prio = sched_get_priority_max(pol);
        param.sched_priority += 5;
        if (prio > 0 && param.sched_priority > prio)
           param.sched_priority = prio;

        pthread_setschedparam(pthread_id, pol, &param);
     }
#ifdef __linux__
   else
     {
        tid = syscall(SYS_gettid);
        errno = 0;
        prio = getpriority(PRIO_PROCESS, tid);
        if (errno == 0)
          {
             prio += 5;
             if (prio > 19)
                prio = 19;

             setpriority(PRIO_PROCESS, tid, prio);
          }
     }
 #endif
}

/*
 * p_hello.c -- a hello program (in pthread)
 */
#define MAX_THREAD 1000

typedef struct {
    int id;
} parm;

void *hello(void *arg)
{
    parm *p=(parm *)arg;
    pid_t tid;
    int prio;
    tid =  syscall(SYS_gettid);
    printf("[%d] Hello from node %d\n", tid, p->id);
    pthread_yield();

    printf("[%d] tid=%lu\n", tid);

    _ecore_thread_pri_drop();

    prio = getpriority(PRIO_PROCESS, tid);
    printf("[%d] New nice value: %d\n", tid, prio);
    return (NULL);
}

void main(int argc, char* argv[]) {
    int n,i;
    pthread_t *threads;
    pthread_attr_t pthread_custom_attr;
    parm *p;

    pid_t tid;
    int prio;

    if (argc != 2)
    {
        printf ("Usage: %s n\n  where n is no. of threads\n",argv[0]);
        exit(1);
    }

    n=atoi(argv[1]);

    if ((n < 1) || (n > MAX_THREAD)) {
        printf ("The no of thread should between 1 and %d.\n",MAX_THREAD);
        exit(1);
    }

    threads = (pthread_t *)malloc(n * sizeof(*threads));
    pthread_attr_init(&pthread_custom_attr);

    p = (parm *)malloc(n * sizeof(parm));
    /* Start up thread */

    tid = syscall(SYS_gettid);
    for (i=0; i<n; i++) {
        prio = getpriority(PRIO_PROCESS, tid);
        printf("[%d] root thread nice value: %d\n", tid, prio);

        p[i].id=i;
        pthread_create(&threads[i], &pthread_custom_attr, hello, (void *)(p+i));
    }

    /* Synchronize the completion of each thread. */

    for (i=0; i<n; i++) {
        pthread_join(threads[i],NULL);
    }
    free(p);
}



SVN revision: 52039
2010-09-09 11:48:31 +00:00
Lucas De Marchi be1b6d32ef Fix common misspellings
Following misspellings were fixed:

alledgedly->allegedly
cant->can't
carefull->careful
consistant->consistent
currenly->currently
dependancy->dependency
descripters->descriptors
doesnt->doesn't
dosen't->doesn't
existant->existent
exmaple->example
inbetween->between
independant->independent
isnt->isn't
mroe->more
neccessary->necessary
occured->occurred
occurence->occurrence
parrallel->parallel
particualr->particular
preceeding->preceding
recieved->received
recieves->receives
seperate->separate
substraction->subtraction
succesfully->successfully
successfull->successful
sucess->success
supress->suppress
usefull->useful
witht->with



SVN revision: 51986
2010-09-08 11:23:42 +00:00
Cedric BAIL d098e05951 * ecore: fix error detection of ecore_pipe_add.
SVN revision: 51926
2010-09-06 16:36:44 +00:00
Carsten Haitzler 9049befccf make 1 func to set lower pri - fall back to setpriority on linux and
try it there only.



SVN revision: 51885
2010-09-04 14:32:50 +00:00
Carsten Haitzler 05cf40fc4d same - back to RR.
SVN revision: 51878
2010-09-04 05:40:38 +00:00
Carsten Haitzler 2c397940de rr->other
SVN revision: 51873
2010-09-04 00:54:53 +00:00
Cedric BAIL b3dd293384 * ecore: ecore_thread are not here to bring your computer down, so
reduce their priority too.


SVN revision: 51862
2010-09-03 13:39:53 +00:00
Carsten Haitzler 2aebc5b458 fix ecore_thread to use pthread correctly. should build on windows now
too.



SVN revision: 51621
2010-08-25 00:26:01 +00:00
Cedric BAIL 243d7c71ad * ecore: struct a b = { 0 }; doesn't mean memset.
SVN revision: 51571
2010-08-23 13:05:57 +00:00
Lucas De Marchi 5a8a8c9014 Convert (hopefully) all comparisons to NULL
Apply badzero.cocci, badnull.coci and badnull2.cocci

This should convert all cases where there's a comparison to NULL to simpler
forms. This patch applies the following transformations:

code before patch               ||code after patch
===============================================================

return a == NULL;                 return !a;

return a != NULL;                 return !!a;

func(a == NULL);                  func(!a);

func(a != NULL);                  func(!!a);

b = a == NULL;                    b = !a;

b = a != NULL;                    b = !!a;

b = a == NULL ? c : d;            b = !a ? c : d;

b = a != NULL ? c : d;            b = a ? c : d;


other cases:

a == NULL                         !a
a != NULL                         a




SVN revision: 51487
2010-08-21 13:52:25 +00:00
Christopher Michael b82186120a Fix 'unused variable'.
SVN revision: 51290
2010-08-18 16:26:20 +00:00
Mike Blumenkrantz 236d58f0de ecore_thread_pool -> ecore_thread_local
SVN revision: 51272
2010-08-18 08:56:44 +00:00
Vincent Torri aaffd2acac fix compilation without thread support
SVN revision: 51267
2010-08-17 19:21:47 +00:00
Carsten Haitzler e286f48745 and now ecore is 1.0.0 ready too.
SVN revision: 51165
2010-08-16 08:17:24 +00:00
Cedric BAIL 2531cd8114 * ecore: fix cancel from another thread.
SVN revision: 51119
2010-08-14 16:15:09 +00:00
Mike McCormack 3bdbb34d64 From: Mike McCormack <mj.mccormack@samsung.com>
This patch implements the ecore main loop in terms of the GTK main loop, so
ecore is a layer on top of glib.

Compared the the current glib integration in ecore, this has the added
advantage of allowing use of EFL libraries in GTK.



SVN revision: 51113
2010-08-14 11:19:03 +00:00
Eduardo de Barros Lima 4cc5441313 Ecore_Getopt: Fix attributions
Modern languages in general use the '=' character for attribution, while
',' character is for something else.



SVN revision: 51082
2010-08-13 15:34:25 +00:00
Lucas De Marchi 6b5d5eab73 Do not compare pointers to 0
SVN revision: 50973
2010-08-10 19:24:38 +00:00
Lucas De Marchi 0a4617ae38 FORMATTING
* Remove vim modelines:
 find . -name '*.[chx]' -exec sed -i '/\/\*$/ {N;N;/ \* vim:ts/d}' \{\} \;
 find . -name '*.[chx]' -exec sed -i '/\/[\*\/] *vim:/d' \{\} \;

* Remove leading blank lines:
 find . -name '*.[cxh]' -exec sed -i '/./,$!d'

If you use vim, use this in your .vimrc:
set ts=8 sw=3 sts=8 expandtab cino=>5n-3f0^-2{2(0W1st0



SVN revision: 50816
2010-08-04 16:57:32 +00:00
Mike Blumenkrantz a475971aaa convert all function pointers to typedefs, add doxy stubs for typedefs.
note: I've chosen to consolidate typedefs where possible to simplify things

my time is limited this week, so feel free to expand on the doxy stubs I've added if you know what they do


SVN revision: 50803
2010-08-04 02:55:20 +00:00