Subversion Repositories HelenOS

Rev

Rev 2283 | Rev 2307 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2283 Rev 2292
Line 50... Line 50...
50
    waitq_initialize(&wq);
50
    waitq_initialize(&wq);
51
 
51
 
52
    tasklet_descriptor_t *tasklet_desc;
52
    tasklet_descriptor_t *tasklet_desc;
53
    //before we start we need to register a tasklet
53
    //before we start we need to register a tasklet
54
    if (!gquiet)
54
    if (!gquiet)
55
        printf("Registering tasklet...");
55
        printf("cpu:%d, Registering tasklet...", CPU->id);
56
    if (!gquiet)
56
    if (!gquiet)
57
        tasklet_desc=tasklet_register(&func, "\nTasklet called and received data from second thread\n");
57
        tasklet_desc=tasklet_register(&func, "\nTasklet called and received data\n");
58
    else
58
    else
59
        tasklet_desc=tasklet_register(&func, "");
59
        tasklet_desc=tasklet_register(&func, "");
60
    if (!gquiet)
60
    if (!gquiet)
61
        printf("Done!\n");
61
        printf("Done!\n");
62
 
62
 
63
    //first we'll try disabling the tasklet
63
    //first we'll try disabling the tasklet
64
    if (!gquiet)
64
    if (!gquiet)
65
        printf("Disabling tasklet...");
65
        printf("cpu:%d, Disabling tasklet...", CPU->id);
66
    tasklet_disable(tasklet_desc);
66
    tasklet_disable(tasklet_desc);
67
    if (!gquiet)
67
    if (!gquiet)
68
        printf("Done!\n");
68
        printf("Done!\n");
69
 
69
 
70
    //we'll schedule the disabled tasklet
70
    //we'll schedule the disabled tasklet
71
    if (!gquiet)
71
    if (!gquiet)
72
        printf("Scheduling tasklet...");
72
        printf("cpu:%d, Scheduling tasklet...", CPU->id);
73
    tasklet_schedule(tasklet_desc);
73
    tasklet_schedule(tasklet_desc);
74
    if (!gquiet)
74
    if (!gquiet)
75
        printf("Done!\n");
75
        printf("Done!\n");
76
 
76
 
77
    //and we'll wait if it gets called. It shouldn't however, because it's disabled
77
    //and we'll wait if it gets called. It shouldn't however, because it's disabled
78
    if (!gquiet)
78
    if (!gquiet)
79
        printf("Waiting 1s...\n");
79
        printf("cpu:%d, Waiting 1s...\n", CPU->id);
80
    waitq_sleep_timeout(&wq,(uint32_t) 1000000,0);
80
    waitq_sleep_timeout(&wq,(uint32_t) 1000000,0);
81
    if (!gquiet)
81
    if (!gquiet)
82
        printf("Done!\n");
82
        printf("cpu:%d, Done!\n", CPU->id);
83
 
83
 
84
    //then we'll try to enable it
84
    //then we'll try to enable it
85
    if (!gquiet)
85
    if (!gquiet)
86
        printf("Enabling tasklet...");
86
        printf("cpu:%d, Enabling tasklet...", CPU->id);
87
    tasklet_enable(tasklet_desc);
87
    tasklet_enable(tasklet_desc);
88
    if (!gquiet)
88
    if (!gquiet)
89
        printf("Done!\n");
89
        printf("Done!\n");
90
   
90
   
91
    //and wait if it gets called this time. It should because it's enabled
91
    //and wait if it gets called this time. It should because it's enabled
92
    if (!gquiet)
92
    if (!gquiet)
93
        printf("Waiting 1s...\n");
93
        printf("cpu:%d, Waiting 1s...\n", CPU->id);
94
    waitq_sleep_timeout(&wq,(uint32_t) 1000000,0);
94
    waitq_sleep_timeout(&wq,(uint32_t) 1000000,0);
95
    if (!gquiet)
95
    if (!gquiet)
96
        printf("Done!\n");
96
        printf("cpu:%d, Done!\n", CPU->id);
97
 
97
 
98
    //finally we'll free the tasklet structure
98
    //finally we'll free the tasklet structure
99
    if (!gquiet)
99
    if (!gquiet)
100
        printf("Freeing...");
100
        printf("cpu:%d, Freeing...", CPU->id);
101
    tasklet_free(tasklet_desc);
101
    tasklet_free(tasklet_desc);
102
    if (!gquiet)
102
    if (!gquiet)
103
        printf("Done!\n");
103
        printf("Done!\n");
104
}
104
}
105
 
105
 
Line 107... Line 107...
107
{
107
{
108
    gquiet = quiet;
108
    gquiet = quiet;
109
    waitq_t wq;
109
    waitq_t wq;
110
    waitq_initialize(&wq);
110
    waitq_initialize(&wq);
111
    tasklet_descriptor_t *tasklet_desc;
111
    tasklet_descriptor_t *tasklet_desc;
112
    thread_t* second_thread;
112
    thread_t* second_thread = NULL;
113
#ifdef CONFIG_SMP
113
#ifdef CONFIG_SMP
-
 
114
    if (!quiet)
-
 
115
        printf("cpus:%d\n", config.cpu_active);
-
 
116
 
114
    if (config.cpu_active >1) {
117
    if (config.cpu_active >1) {
115
        second_thread = thread_create(&running_tasklet, NULL, TASK, THREAD_FLAG_WIRED,"running tasklet", false);
118
        second_thread = thread_create(&running_tasklet, NULL, TASK, THREAD_FLAG_WIRED,"running tasklet", false);
116
        if (CPU->id == 0)
119
        if (CPU->id == 0)
117
            second_thread->cpu = &cpus[1];
120
            second_thread->cpu = &cpus[1];
118
        else
121
        else
Line 121... Line 124...
121
    }
124
    }
122
#endif
125
#endif
123
 
126
 
124
    //before we start we need to register a tasklet
127
    //before we start we need to register a tasklet
125
    if (!quiet)
128
    if (!quiet)
126
        printf("Registering tasklet...");
129
        printf("cpu:%d, Registering tasklet...", CPU->id);
127
    if (!quiet)
130
    if (!quiet)
128
        tasklet_desc=tasklet_register(&func, "\nTasklet called and received data\n");
131
        tasklet_desc=tasklet_register(&func, "\nTasklet called and received data\n");
129
    else
132
    else
130
        tasklet_desc=tasklet_register(&func, "");
133
        tasklet_desc=tasklet_register(&func, "");
131
    if (!quiet)
134
    if (!quiet)
132
        printf("Done!\n");
135
        printf("Done!\n");
133
 
136
 
134
    //first we'll try disabling the tasklet
137
    //first we'll try disabling the tasklet
135
    if (!quiet)
138
    if (!quiet)
136
        printf("Disabling tasklet...");
139
        printf("cpu:%d, Disabling tasklet...", CPU->id);
137
    tasklet_disable(tasklet_desc);
140
    tasklet_disable(tasklet_desc);
138
    if (!quiet)
141
    if (!quiet)
139
        printf("Done!\n");
142
        printf("Done!\n");
140
 
143
 
141
    //we'll schedule the disabled tasklet
144
    //we'll schedule the disabled tasklet
142
    if (!quiet)
145
    if (!quiet)
143
        printf("Scheduling tasklet...");
146
        printf("cpu:%d, Scheduling tasklet...", CPU->id);
144
    tasklet_schedule(tasklet_desc);
147
    tasklet_schedule(tasklet_desc);
145
    if (!quiet)
148
    if (!quiet)
146
        printf("Done!\n");
149
        printf("Done!\n");
147
 
150
 
148
    //and we'll wait if it gets called. It shouldn't however, because it's disabled
151
    //and we'll wait if it gets called. It shouldn't however, because it's disabled
149
    if (!quiet)
152
    if (!quiet)
150
        printf("Waiting 1s...\n");
153
        printf("cpu:%d, Waiting 1s...\n", CPU->id);
151
    waitq_sleep_timeout(&wq,(uint32_t) 1000000,0);
154
    waitq_sleep_timeout(&wq,(uint32_t) 1000000,0);
152
    if (!quiet)
155
    if (!quiet)
153
        printf("Done!\n");
156
        printf("cpu:%d, Done!\n", CPU->id);
-
 
157
 
154
 
158
 
155
    //then we'll try to enable it
159
    //then we'll try to enable it
156
    if (!quiet)
160
    if (!quiet)
157
        printf("Enabling tasklet...");
161
        printf("cpu:%d, Enabling tasklet...", CPU->id);
158
    tasklet_enable(tasklet_desc);
162
    tasklet_enable(tasklet_desc);
159
    if (!quiet)
163
    if (!quiet)
160
        printf("Done!\n");
164
        printf("Done!\n");
161
   
165
   
162
    //and wait if it gets called this time. It should because it's enabled
166
    //and wait if it gets called this time. It should because it's enabled
163
    if (!quiet)
167
    if (!quiet)
164
        printf("Waiting 1s...\n");
168
        printf("cpu:%d, Waiting 1s...\n", CPU->id);
165
    waitq_sleep_timeout(&wq,(uint32_t) 1000000,0);
169
    waitq_sleep_timeout(&wq,(uint32_t) 1000000,0);
166
    if (!quiet)
170
    if (!quiet)
-
 
171
        printf("cpu:%d, Done!\n", CPU->id);
-
 
172
#ifdef CONFIG_SMP
-
 
173
        if (config.cpu_active >1) {
-
 
174
            printf("Joining with the second thread...");
-
 
175
            thread_join(second_thread);
167
        printf("Done!\n");
176
            printf("Done\n");
-
 
177
        }
168
 
178
 
-
 
179
#endif
169
    //finally we'll free the tasklet structure
180
    //finally we'll free the tasklet structure
170
    if (!quiet)
181
    if (!quiet)
171
        printf("Freeing...");
182
        printf("cpu:%d, Freeing...", CPU->id);
172
    tasklet_free(tasklet_desc);
183
    tasklet_free(tasklet_desc);
173
    if (!quiet)
184
    if (!quiet)
174
        printf("Done!\n");
185
        printf("Done!\n");
175
 
186
 
176
 
187